AMT Help Files

ATTACHTOBOX

Syntax Color Legend
Command
Mandatory parameter
Optional parameter
Mandatory keyword
Optional keyword

Syntax

ATTACHTOBOX (<Fieldname>, <Filename>)

Description

Use the ATTACHTOBOX command to assign the content of an existing contents file (with any filename) to a listbox or combobox on a form. This is supported only when the Memory Based property for that control is set to false in the Object Inspector.

Diagram

ATTACHTOBOX command diagram showing source file input and listbox or combobox target.

Returned value type

None

Parameters

Parameter Description
<Fieldname>

The name and location of a layout control element. The syntax for a field name is as follows:
'<Formname>.[<Occurs>]<Layout fieldname>'
Where:
<Occurs> indicates which element of the specified layout control must be filled. The syntax for <Occurs> depends on the setting of the OccursData property:

  • For controls with only vertical occurrences, use xx. For example, attachtobox ('FORM_BOXES.' + '02' + 'lbxselproduct', 'FieldContent.txt') uses the 2nd vertical control.
  • For controls with only horizontal occurrences, use xxxx. For example, attachtobox ('FORM_BOXES.' + '0003' + 'lbxselproduct', 'FieldContent.txt') uses the 3rd horizontal control.
  • For controls with both vertical and horizontal occurrences, xxxx_xxxx should be used, where the numbers before the underscore (_) represent the vertical occurrence and the number after the underscore represents the horizontal occurrence. For example, attachtobox ('FORM_BOXES.' + '0001_0002' + 'lbxselproduct', 'FieldContent.txt') uses the control in the 1st column, 2nd row.

To avoid overlap when opening listbox or combobox elements, choose a suitable vertical offset setting.

<Formname> is the name of the form. Instead of a specific form name, the asterisk (*) can be specified to assign all forms.
<Layout fieldname> is the name of the listbox or combobox within the specific form or all the forms (depending on <Formname>) to which values are inserted.

<Filename> Expression that gives the name of the text file (considered a single string) from which data is read. It is also possible to use a file ID as filename if the file ID has a physical file location set. The file will then be copied to the default listbox folder as set in the base path.

Remarks

The file is read, and the listbox or combobox is filled with the content of that file. Within the file, delimiters define which value must be placed where. This file should be located in the listbox folder as set in the basepath.

The ATTACHTOBOX command can be used to fill the listbox or combobox with a file that applies only to the currently logged-on user. A different file can be used for each user, depending on user rights. Files can be updated during the night. This way, users always have the most recent information at hand.

If you prefer to let AMT handle the files, and you don't want to point to a specific file, you can use the FILLBOX command. However, the ATTACHTOBOX command always provides better performance.

Example

The file "FieldContent.txt" has the following content:

| ordjan | Orders January
| offjan | Offers January
| ordfeb | Orders February
| offfeb | Offers February
// When in the code
attachtobox ('*.lbxselproduct', 'FieldContent.txt')

// All the layout controls that are called "lbxselproduct"
// are filled with the content of the file "FieldContent"

Return to

Commands

Contents