Name
ListRequest -- prompt choice from a list of options (V5.0)
Synopsis
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. The fourth argument is optional and can be used to preselect one of the choices in the list. Simply pass the index of the entry to preselect as the fourth argument. Indices start at 0 for the first entry and run through number of entries minus 1. If the fourth argument is omitted or out of range, nothing will be selected.

When ListRequest() returns, you will receive the index of the list entry that the user selected as the return value. If the user does not select an item or cancels the requester, -1 will be returned.

Starting with Hollywood 6.0 you can pass an empty string ("") in the first parameter. 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
active
optional: index of list entry to preselect when presenting the requester to the user (defaults to -1 which means do not preselect anything)
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