Navigation:  ThinBASIC Modules > Core (thinBasic Core Engine) > Numeric functions >

CHOOSE

Previous pageReturn to chapter overviewNext page

 

Description

 

Return one of several values, based upon the value of an index.

 

Syntax

 

n = CHOOSE(index, choice1 [, choice2] ...)

 

Returns

 

Number

 

Parameters

 

Name

Type

Optional

Meaning

index

Numeric

No


choice1

Numeri

No

An expression evaluated as number

choice2

Numeri

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, zero is returned accordingly.

 

CHOOSE expects choices of numeric type.

 

Restrictions

 

See also

 

Choose$, SELECT

 

Examples