Chapter 6 RAPID!
Commands
WCDMA Options Version 6.20
173
IF ... THEN, ELSE, ELSEIF, END
IF
The following example reverts the string Matter$ into the
string AntiMatter$:
AntiMatter$ = ""
FOR i=len(Matter$) TO 1 STEP –1
AntiMatter$ = AntiMatter$ + MID$(Mat-
ter$, i, 1)
NEXT i
Syntax
Syntax 1
IF boolExp1 THEN instructions1 [ ELSE
instructions2 ]
Syntax 2
IF boolExp2 THEN
[ instructions3 ]
[ ELSEIF boolExp3 THEN
[ instructions4 ] ]
[ ELSE
[ instructions5 ] ]
END IF
Parameters
boolEXP1/2/3 are boolean expressions,
instructions1/2/3/4/5 are an (optional) number of
program lines.
Description
Depending on a boolean expression or condition (
bool-
Exp
), the program will resume with different sets of
commands.
There are two different forms of this command, indicated
by ‘Syntax 1’ and ‘Syntax 2’ above.
Syntax 1 is the ‘one-line’ command. If
boolExp1 is true
(or a numeric value is <> 0), the command(s) following
THEN will be executed. If boolExp1 is false (or a
numeric value = 0), the commands following the optional
ELSE will be executed.
Syntax 2 is the ‘multiline’ version of the command. This
syntax should be used in case there are several com-
mands to be executed, depending on the conditions.
In case
boolExp2 is true, instructions3 will be exe-
cuted.
If
boolExp2 is false, the subsequent ELSEIF command
will be looked for. If this is true (i.e.
boolExp3 is true),
instructions4 will be executed.
There may be several
ELSEIF conditions within one IF-
clause.
Should all
boolExp2/3 be false, instructions5 will
be performed.
Examples
IF tired THEN PRINT "Go to bed!" ELSE
PRINT "Go shopping!"