List Box (Single Field Single Column) Control Syntax

Syntax

[ [ %Directives% ]. Width [ " ][, Height [ " ]] Variable_Name ^# Choices [ ! Event ][ ? Enabled ] ]

Arguments

%Directives%

Refer to Xdialog Language Directives and Operators.

^#

Character. The leading [ and trailing ] and the ^# characters are required.

Width

Numeric. The width of the control.

Height

Numeric. The height of the control.

Variable_Name

Character. The name of a character variable to receive the user selection, or a numeric variable to receive the index value of the selected radio button. The index of the top-most button is 1.

Choices

Character. See Choices Syntax. You must either use the use {DATA} command or the K Directive to preserve the formatting of selected items.

Event

Character. Optional. See Event Syntax.

Enabled

Logical. Optional. See Enabled Syntax. The control is grayed out when disabled.

Description

One or more List Box objects may appear inside the Format section of a UI_DLG_BOX() function. To clear or repopulate a list box, simply redefine its Choices variable.

You must not have any space characters in the finished command, except those that may be inside entries in the Choices list.
You must have an Event if you want to respond to the user's selection in the Code section of the dialog box.

Example 

For example, the following script creates a list box ten characters wide and five lines tall:

mode = 1
choices = <<%dlg%
Shared
Read only
Exclusive
%dlg%
result=ui_dlg_box("Title",<<%dlg%
Filename:| .32filename;
Open as:;
Mode:| .10,5mode^#choices;

%dlg% )

You can also use an array of character variables to populate the list box.

dim mode as N
dim choices3 as C
choices1 = "Shared"
choices2 = "Read only"
choices3 = "Exclusive"
mode = 1
result=ui_dlg_box("Title",<<%dlg%
Filename:| .32filename;
Open as:;
Mode:| .10,5mode^#choices;

%dlg% )

This approach produces the same result. Note the uses of the \ (Backslash) character to distinguish between the "]" in the choices[] variable and the list box syntax.

dim mode as N
dim choices3 as P
choices1.mode = "Shared"
choices2.mode = "Read only"
choices3.mode = "Exclusive"
mode = 1
result=ui_dlg_box("Title",<<%dlg%
Filename:| .32filename;
Open as:;
Mode:| [.10,5mode^#choices\.mode];

%dlg% )

See Also