Caché MultiValue Basic Reference
Conditionally executes a group of statements, depending on the value of an expression.
IF condition THEN statements
IF condition ELSE elsestatements
IF condition THEN statements ELSE elsestatements
statement performs a boolean test on condition
, and then executes either the THEN clause (condition
=1 (true)) or the ELSE clause (condition
You can omit or include either the THEN clause or the ELSE clause. If condition
=1 and the THEN clause is omitted, or condition
=0 and the ELSE clause is omitted, IF
returns the empty string. Further IF
statements can be nested within THEN or ELSE clauses.
can be coded as a single-line statement, or as a code block statement using the END keyword. You can use any of the single-line forms for short, simple tests. However, the block form provides more structure and flexibility than the single-line form and is usually easier to read, maintain, and debug.
When executing a block IF
is tested. If condition is True
, the statements following THEN
are executed. If condition is False
, the statements following ELSE
are executed. After executing the statements following THEN
, execution continues with the statement following END
What follows the THEN
keyword is examined to determine whether or not a statement is a block IF
. If anything other than a comment appears after THEN
on the same line, the statement is treated as a single-line IF
For a block IF
statement, the IF
keyword must be the first statement on a line. The block IF
must end with an END
expression can be a compound expression, using = (equal to), # (not equal to), and other the comparison operators. You can use literals, variables, and dynamic arrays
expression elements. Multiple test expressions can be associated by AND and OR logical operators.