Please enable JavaScript to view this site.

thinBasic Help Manual

Navigation: ThinBASIC Core Language > Program Flow

IF / THEN / ELSE / ELSEIF / END IF

Scroll Prev Top Next More

* * 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

 

Create IF/THEN/ELSE constructs with multiple lines and/or conditions.

 

Syntax 1

 

IF logical_expression THEN

 {statements}

[ELSEIF logical_expression THEN

 {statements}]

[ELSE

 {statements}]

END IF

 

Syntax 2

 

IF logical_expression THEN {statements}

 

Returns

 

Parameters

 

Remarks

 

Restrictions

 

See also

 

Examples

 

RANDOMIZE

 

DIM X   AS NUMBER VALUE ( RND * 500 ) + 1

DIM Msg AS STRING

 

IF X <= 10 THEN

 Msg = X & ": The number <= 10"

ELSEIF X <= 20 THEN

 Msg = X & ": The number > 10 and <= 20"

ELSE

IF X < 50 THEN

   Msg = X & ": The number is > 20 and less than 50"

ELSEIF X < 100 THEN

   Msg = X & ": Greater than 49 and less than 100"

ELSE

   Msg = X & ": The number is 100 or greater"

END IF

END IF

 

IF Msg <> "" THEN

 MSGBOX 0, Msg

END IF

 

 

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