IF Verb

Syntax

IF <numberic> THEN statements {ELSE statements} {ENDIF | FI}

Description

For BBj-specific information, see the IF..THEN..ELSE Statements.

The IF Verb allows conditional execution of statements. PRO/5 evaluates the numeric expression and determines if it is true (nonzero) or false (zero). For true results, execution continues with the first statement following the THEN and skips the statements following the ELSE. If false, execution continues with the first statement following the ELSE or FI*, or if there is no ELSE/FI* clause, execution continues at the next line in the program. IF-THEN-ELSE statements can be nested. Each ELSE belongs to the most recent THEN not already paired with an ELSE. Each FI* belongs to the most recent IF not already paired with a FI*.

The FI* clause may be used to terminate an IF statement, if additional statements follow in the same line that are not to be affected by the IF condition. Normally, all statements following a THEN or ELSE are conditionally executed.

* ENDIF may be used in place of FI.

Example

1000 IF X$="YTD" THEN PRINT "TRUE"ELSE PRINT "FALSE"
1010 IF A=B THEN IF C=D THEN PRINT "YES" ELSE PRINT "MAYBE"ELSE PRINT "NO"
1020 IF FID(1)="LP" THEN PRINT (1)'FF' FI;
1020:PRINT (1)HEADER$

Note the use of FI in the first part of line 1020. The last PRINT statement is not affected by the IF. Also note that there is no semicolon (;) before the FI.

See Also

Verbs - Alphabetical Listing