if (boolean expression)
statements
endif
If boolean expression is evaluated to true then statementes are executed.
If boolean expression is evaluated to false then statementes are not executed.
if (boolean expression)
statements1
else
statements2
endif
If boolean expression is evaluated to true then statementes1 are executed.
If boolean expression is evaluated to false then statementes2 are executed.
if (boolean expression1)
statements1
elseif (boolean expression2)
statements2
endif
If boolean expression1 is evaluated to true then statementes1 are executed.
boolean expression2 will not be evaluated.
If boolean expression1 is evaluated to false then boolean expression2 is evaluated.
If boolean expression2 is evaluated to true then statementes2 are executed.
If boolean expression2 is evaluated to false then statementes2 are not executed.
for
for (counter,start,stop,step)
statements
next
Execute statements a number of time determinated by the number of iterations needed
for counter to reach stop, starting with start with an increment of step .
while
while (boolean expression)
statements
wend
The statements are executed as long as the boolean expression is evaluated to true.
repeat
repeat
statements
until (boolean expression)
The statements are executed until boolean expression becomes true.
Procedures
To better organize your code you can write and use procedures.
A procedure is a block of statements that can be called from the script.
It is not interpreted where is declared (described) but only when called.
The format of a procedure is as follows:
procedure aname
statement
........
statement
procend
So it must begin with the "procedure" word followed by a name and ended with the "procend" word.
To call it somewhere in script do it like this:
.........
statement
aname
statement
.........
So the call is done with the name and only the name on one line.
Procedures can call another procedure and can be recursive.
break
Forces premature termination of a loop (for, while, repeat)
Example:
while (1==1)
if (boolean expression)
break
endif
wend
This forces the exit from the (here endless) while loop when boolean expression is evaluated to true.
exit
Forces premature termination of a procedure.
Example:
procedure myex
while (1==1)
if (boolean expression)
exit
endif
wend
.......
procend
This forces the exit from the hole procedure when boolean expression is evaluated to true.