Purpose |
Return one of several values, based upon the value of an index. |
Syntax |
y
= CHOOSE(index&, choice1
[, choice2] ...) |
Remarks |
These functions take any number of choice arguments,
and return the argument identified by index&. If index&
evaluates to one, choice1 is returned, if two, choice2 is
returned, etc. If index& is less than one or greater
than the number of choices provided, zero or an empty
CHOOSE expects choices of any
|
Restrictions |
PowerBASIC only evaluates the selected choice at run-time, not all of them. This ensures optimum execution speed, as well as the elimination of unanticipated side effects. |
See also |
IIF, IIF&, IIF$, MAX, MAX&, MAX$, MIN, MIN&, MIN$, SWITCH, SWITCH&, SWITCH$, SELECT |
Example |
y& = 4 a$ = CHOOSE$(y&, "Bill", "Bob", "Bruce", "Barry") |
Result |
a$ = "Barry" |