Navigation: thinBasic Modules > Core > String handling > CHOOSE$ |
|
Description
Return one of several values, based upon the value of an index.
Syntax
s = CHOOSE$(index, choice1 [, choice2] ...)
Returns
String
Parameters
Name |
Type |
Optional |
Meaning |
index |
Numeric |
No |
|
choice1 |
String |
No |
An expression evaluated as string |
choice2 |
String |
Yes |
... |
... |
Remarks
This function takes 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, an empty string is returned accordingly.
CHOOSE$ expects choices of string type.
Restrictions
See also
Examples
Thanks to Abraxas for the following script example
' Usage of the Choose$ Instruction example
' Returns the indexed String
Dim Mychoice As DWORD VALUE 3
Dim Mystring As String VALUE "Option 3"
Dim RetString As String
RetString = CHOOSE$ (Mychoice, "Option 1", "Option 2", MyString)
MSGBOX 0, RetString
© 2004-2008 thinBasic. All rights reserved. | Version 1.7.0.0 | Web Site: http://www.thinbasic.com |