List Box Control
A list box control is a variant of the combo box control, except that the list is typically displayed with several choices visible, so that the user does not have to click a button to display the choices. You can turn a combo box into a list box by changing the '^=' directive to '^#'. The syntax for a list box object is:
Where choice1, choice2, choiceN are the actual choices, or choice_variable is the name of a string that contains CR-LF delimited choices, or choice_array is the name of a array that contains the choices. The value of variable_name is a base-1 index if the variable is declared as Numeric. If undeclared or left un-initialized, the variable is a string that returns the text of the choice that is selected. The size parameter is specified as characters_wide,lines_high. For example, the following script is the same as the combo box example above, except that the combo box has been converted into a list box:
mode = 1 choices = <<%dlg% Shared Read only Exclusive %dlg% result=ui_dlg_box("Title",<<%dlg% Filename:| [.32filename]; Open as:; Mode:| [.10,5mode^#choices]; %dlg% )
This script creates this dialog:
In the above script, when the user changes the highlighted row in the list box, the variable "mode" is set to the appropriate value, 1, 2, or 3. If "mode" had been declared as a character variable, it would be set to "Shared", Read only", or "Exclusive".
The following script demonstrates quite graphically the difference between declaring mode as a numeric or text variable. This script displays two combo boxes, one with the result variable declared as a numeric variable and the other with the result variable declared as a character variable. The dialog displays the value of each variable.
Mode_n = 1 Mode_c = "Exclusive" choices = <<%dlg% Shared Read only Exclusive %dlg% result=ui_dlg_box("Title",<<%dlg% Filename:| [.32filename]; Open as:; Mode:| [.10,5mode_n^#choices]| [.10mode_n]; Mode:| [.10,5mode_c^#choices]| [.10mode_c]; %dlg% )
This script creates this dialog with two list boxes:
Notice how the variable changes when you change the selection in each of the list boxes. In the first case, the variable ( mode_n ) take on the values: 1, 2 and 3. In the second case the variable ( mode_c ) takes on the values: "Shared", "Read only" and "Exclusive"