listbox

Displays a dialog box with a list box, and ask an item to user. (version 4.78 or later)

listbox <message> <title> <string array> [<selected>] [<keyword parameter>...]

Parameters

string <message>
It is displayed in the dialog box.
string <title>
It is displayed as the dialog box title.
array <string array>
It is displayed as the list box items.
integer <selected> (version 4.89 or later)
It is selected first item by specifying the zero-based index of the array. This argument is optional. When this option is omitted, no item is selected.

keyword parameters : optional, multiple allowed, random order
string 'dblclick=on' (default=off) (version 5.3 or later)
Enable item selection by double-clicking.
string 'minmaxbutton=on' (default=off) (version 5.3 or later)
Enable Minimize/Maximize button.
string 'minimize=on' (default=off) (version 5.3 or later)
Display in minimized state.
string 'maximize=on' (default=off) (version 5.3 or later)
Display in maximized state.
string 'listboxsize=WxH' (default=26x6) (version 5.3 or later)
Specify the size of the list box. W:width (horizontal character count), H:height (vertical character count).
Example 'listboxsize=60x20' (for 60 characters horizontally and 20 characters vertically)

Return Value

System variable <result>
If the user selects one of items, it is set to from 0 to N-1.
If the user cancels, it is set to -1.

Remarks

The listbox macro command shows all selected items of the <string array> array.
If the <string array> is defined as bigger entries than selected numbers as follows, the empty string will be shown at last.

strdim msg 4
msg[0] = 'Banana'
msg[1] = 'Apple'
msg[2] = 'Orange'
listbox 'Select your favorite food.' 'Confirmation' msg

; displays 4 items
Banana
Apple
Orange
[Empty string]

(version 4.89 or later)
When the <selected> parameter is specified, an item of the list box can be selected at first.
If the parameter is omitted, the default value is 0.

Example

strdim msg 3
msg[0] = 'Banana'
msg[1] = 'Apple'
msg[2] = 'Orange'
listbox 'Select your favorite food.' 'Confirmation' msg
sprintf2 var "%d" result
messagebox var "result"
; result
;   -1: Cancel
;    0: Banana
;    1: Apple
;    2: Orange
strdim msg 7
msg[0] = 'Sunny'
msg[1] = 'Cloudy'
msg[2] = 'Rainy'
msg[3] = 'Windy'
msg[4] = 'Snowy'
msg[5] = 'Foggy'
msg[6] = 'Unknown'
; The seventh entry is selected by default.
listbox "How's today's weather?" 'Confirmation' msg 6
sprintf2 var "%d" result
messagebox var "result"
strdim msg 9
selected = 0
msg[0] = "listbox msg[selected] title msg selected 'listboxsize=70x10'"
msg[1] = "listbox msg[selected] title msg selected 'listboxsize=70x10' 'dblclick=on'"
msg[2] = "listbox msg[selected] title msg selected 'listboxsize=70x10' 'minmaxbutton=on'"
msg[3] = "listbox msg[selected] title msg selected 'listboxsize=70x10' 'minimize=on'"
msg[4] = "listbox msg[selected] title msg selected 'listboxsize=70x10' 'maximize=on'"
msg[5] = "listbox msg[selected] title msg selected 'listboxsize=70x10' 'minmaxbutton=on' 'dblclick=on'"
msg[6] = "listbox msg[selected] title msg selected 'listboxsize=100x5'"
msg[7] = "listbox msg[selected] title msg selected 'listboxsize=10x20'"
msg[8] = "listbox msg[selected] title msg selected"
:select
sprintf2 title 'selected = %d' selected
execcmnd msg[selected]
selected=result
if selected = -1 then
  exit
endif
goto select

See also