4D v14.3OBJECT SET LIST BY REFERENCE |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
OBJECT SET LIST BY REFERENCE
OBJECT SET LIST BY REFERENCE
The OBJECT SET LIST BY REFERENCE command defines or replaces the list associated with the object(s) designated by the object and * parameters, with the hierarchical list referenced in the list parameter. Passing the optional * parameter indicates that the object parameter is an object name (string). If you do not pass this parameter, it indicates that the object parameter is a field or variable. In this case, you pass a field or variable reference instead of a string (field or variable object only). By default, if you omit the listType parameter, the command defines a source choice list (choice of values) for the object. You can designate any type of list in the listType parameter. To do this, you just need to pass one of the following constants found in the "Form Objects (Properties)" theme:
In list, pass the reference number of the hierarchical list that you want to associated with the object. This list must have been generated using the Copy list, Load list oR New listcommand. To end the association of a list with an object, you can just pass 0 in the list parameter for the type of list concerned. Removing a list association does not delete the list reference from memory. Remember to call the CLEAR LIST command when you no longer need the list. This command is particularly interesting in the context of a pop-up or combo box associated with a variable or a field (see the Design Reference manual). In this case, the association is dynamic and any change in the list is copied to the form. When the object is associated with an array, the list is copied into the array and any changes to the list are not available automatically (see example 5). Associating a simple choice list (default list type) to a text field: vCountriesList:=New list Associating the "vColor" list as a simple choice list with the "DoorColor" pop-up/drop-down list: vColor:=New list Now you want to associate the "vColor" list with a combo box named "WallColor". Since this combo box is enterable, you want to make sure certain colors, such as "black," "purple," etc., cannot be used. These colors are placed in the "vReject" list: OBJECT SET LIST BY REFERENCE(*;"WallColor";Choice list;vColor) You want to remove the list associations: OBJECT SET LIST BY REFERENCE(*;"WallColor";Choice list;0) This example illustrates the difference in how the command works when applied to a pop-up menu associated with a text array or one associated with a text variable. There are two pop-up menus in a form: The contents of these pop-up menus is set using the <>vColor list (containing color values). The following code is executed when the form is loaded: ARRAY TEXT(arr1;0) //arr1 pop up During execution, both menus propose the same values:
Then you run the following code, for example by means of a button: APPEND TO LIST(<>vColor;"White";5) Only the menu associated with the Text field is updated (by means of the dynamic reference): In order to update the list associated with the pop-up managed by array, you need to call the OBJECT SET LIST BY REFERENCE command again to copy the contents of the list. |
PROPERTIES
Product: 4D
HISTORY
SEE ALSO
OBJECT Get list reference ARTICLE USAGE
4D Language Reference ( 4D v14 R3) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||