Syntax
if expression
statements...
[ elseif expression ]
[ statements... ]
[ else ]
[ statement... ]
endif
Description
The if statement evaluates the expression; if it is true (nonzero), the following statements are executed; otherwise, they are skipped until the next elseif, else, or endif statement. The statements following an else statement are executed only if the corresponding if expression was false. Elseif statements are equivalent to nested if's as shown by the following equivalent examples:
if expression1 if expression1
statements ... statements ...1
elseif expression2 else
statements ...2 if expression2
elseif expression3 statements ...2
statement...3 else
else if expression3
statements ...4 statements ...3
endif else
statements ...4
endif
endif
endif
The value of an if statement is the value of the last statement executed within the if. If no statement was executed, the value of the if statement is an empty string.
Example
if price > 100.00
"price is too large"
elseif price < 10.00
"price is too small"
endif
The following two if statements are equivalent
if quantity > 10
"quantity is too large"
else
""
endif
if quantity > 10
"quantity is too large"
endif