Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Returns the first value following the first expression evaluating as True..

 

Syntax

 

n = Switch(expr1, NumericVal1 [[, expr2, NumericVal2], ...])

 

Returns

 

Number

 

Parameters

 

Name

Type

Optional

Meaning

expr1

Number

No

Any logical expression valuating to TRUE or FALSE

NumericVal1

Number

No

Numeric expression to return in case expr1 valuate to TRUE

 

Remarks

 

If expr1 evaluates TRUE, NumericVal1 is returned, if expr2 evaluates TRUE, NumericVal2 is returned, etc.

 

Switch returns the matching value parameter from the first TRUE evaluation of the control expressions, evaluated from left to right in the list. Therefore, it would be wise to place the most likely selections at the front of the Switch list to achieve the utmost efficiency.  If no expressions evaluate to TRUE, then a zero (0) value is returned.

 

Only the chosen value (one of NumericVal1, NumericVal2, NumericVal3 …) is evaluated at run-time; the other value parameters are not. This ensures optimum execution speed, as well as the elimination of unanticipated side effects.

 

Restrictions

 

See also

 

Choose$, IF, IIF$, SELECT, Switch$

 

Examples

 

 

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software