AMT Help Files

ATTACHTOBOX

Syntax

Command
Mandatory parameter
Optional parameter
Mandatory keyword
Optional keyword

ATTACHTOBOX (<Fieldname>, <Filename>)

Description

With the ATTACHTOBOX command, you assign the content of an existing contents file, of any name, to a list- or combobox on a form. This will only be supported if the Memory Based property for that particular control has been set to false in the object inspector.

Diagram

Returned value type

None

Parameters

Parameter Description
<Fieldname>

The name and location of a layout control element. The syntax for a fieldname is as follows:
'<Formname>.[<Occurs>]<Layout fieldname>'
Where:
<Occurs> is the value to indicate which element for the specified layout control has to be filled. The syntax for <Occurs> depends on the settings of the OccursData property:

  • For controls with only vertical occurrences, xx should be used. E.g.  attachtobox ('FORM_BOXES.' + '02' + 'lbxselproduct', 'FieldContent.txt') will use the 2nd vertical control.
  • For controls with only horizontal occurrences, xxxx should be used. E.g.  attachtobox ('FORM_BOXES.' + '0003' + 'lbxselproduct', 'FieldContent.txt') will use the 3rd horizontal control.
  • For controls with both vertical and horizontal occurrences, xxxx_xxxx should be used, where the numbers before the underscore (_) is the vertical occurrence and the number after the underscore is the horizontal occurrence.  E.g.  attachtobox ('FORM_BOXES.' + '0001_0002' + 'lbxselproduct', 'FieldContent.txt') is the control in the 1st column, 2nd row.
To avoid overlapping when opening listbox or combobox elements it is important to choose a suitable setting for the vertical offset.

<Formname> is the name of the form. Instead of a specific formname, 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 the values are inserted.
<Filename> Expression giving the name of the textfile (that is considered as a single string) from which the 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 basepath.

Remarks

The file is read and the list/combo box(es) is/are filled with the content of that file. Within the file, delimiters are used to 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 the file that applies only to a specific user who is logged on, and a different file can be made for each user depending on the users rights. The files can be updated during the night. This way the users will 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 will always give a better performance result.

Example


The file "FieldContent.txt" has the following content

ordjan | Orders January
offjan | Offers Janyary
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