Name
ListRequest -- prompt choice from a list of options (V5.0)
Synopsis
choice = ListRequest(title$, body$, choices[, t])
Deprecated syntax
choice = ListRequest(title$, body$, choices[, active])
Function
This command can be used to present a list of choices to the user and ask him to select one of the list entries. The first argument specifies the title text for the requester's dialog window. The second argument specifies the body text that shall appear above the list of choices. The third argument must be a table containing an arbitrary number of strings from which the user shall be able to choose.

When ListRequest() returns, you will receive the index of the list entry that the user has selected as the return value. If the user hasn't selected an item or cancelled the requester, -1 will be returned.

ListRequest() supports several additional arguments. Before Hollywood 9.0, those had to be passed as optional parameters (see above). Since Hollywood 9.0, however, it is recommended to use the new syntax, which has a single optional table argument that can be used to pass one or more optional arguments to ListRequest().

The following table fields are recognized by this function:

Active:
This table tag can be used to preselect one of the choices in the list. Simply pass the index of the entry to preselect in the Active table tag. Indices start at 0 for the first entry and run through number of entries minus 1. If Active is omitted or out of range, nothing will be preselected.

X:
Initial x-position for the list requester on the screen. Not all platforms support this. (V9.0)

Y:
Initial y-position for the list requester on the screen. Not all platforms support this. (V9.0)

Width:
Initial width for the list requester dialog. Not all platforms support this. (V9.0)

Height:
Initial height for the list requester dialog. Not all platforms support this. (V9.0)

Starting with Hollywood 6.0 you can pass an empty string ("") as title$. In that case, the requester will use the title specified in the @APPTITLE preprocessor command.

Inputs
title$
title for the requester
body$
body text to display above the list view widget
choices
table containing a number of string entries that constitute the available choices
t
optional: table containing further arguments (see above) (V9.0)
Results
choice
index of the user's selection or -1 if the user cancelled the requester; indices start at 0 for the first entry and run through the number of entries minus 1
Example
r = ListRequest("User prompt", "Which of these is not an island?",
{"Australia", "Fiji", "New Zealand", "Easter Island", "Hawaii",
"Goa", "Madagascar", "Maldives", "Seychelles"})
If r = -1
  Print("You chose the chicken exit!")
ElseIf r = 5
  Print("That's right, congratulations!")
Else
  Print("Sorry, but that is an island...")
EndIf
The code above shows how to use ListRequest() for a little quiz.

Show TOC