IF-THEN-ELSE
Conditionally execute one of two statements (alternate)
WTSupported in traditional Synergy on Windows
|
WNSupported in Synergy .NET on Windows
|
USupported on UNIX
|
VSupported on OpenVMS
|
IF condition[ THEN] statement_1 [ELSE statement_2]
Arguments
condition
An expression whose value controls which statement is executed.
statement_1
A single or compound statement to be executed if condition is true.
statement_2
(optional) A single or compound statement to be executed if condition is false.
Discussion
The IF-THEN-ELSE statement (alternate form) executes one of two statements based on the value of an expression.
The result of condition is evaluated for its truth value. If it’s true, statement_1 is executed and statement_2 is skipped; if it’s false, statement_1 is skipped and statement_2 is executed (if present).
Statement_1, statement_2, and the THEN and ELSE keywords can each begin on the next logical line.
By default, Synergy DBL requires that an IF statement with a THEN present must also have an ELSE, and the ELSE belongs to the last THEN in the same lexical level. However, if you specify either the alternate IF compiler option or system option #31, Synergy DBL recognizes an alternate, non-ANS DIBOL form of the IF statement. In the alternate form of the IF statement, the THEN is optional and the ELSE matches the last IF statement, not the last THEN.
See also
- Compiler options for more information about the alternate IF compiler option
- System option #31
Examples
In the following example, if system option #31 or the alternate IF compiler option is set, statement2 is processed when answer is equal to Y and choice is not equal to 1.
if (answer .eq. 'Y') then if (choice .eq. 1) statement1 else statement2