| Directives |
|
| Form | 1.
Set Conditions:
2. Set Conditions, Multiple Line Format:
|
|||||||||||||||||||||||||||
| Description | Use
the IF directive to control the
execution of various ProvideX/PxPlus statements based on
the result of a Boolean TRUE/FALSE value. If the expression returns a TRUE value (non-zero for numeric, non-null for string) then ProvideX/PxPlus continues execution with the directives following the THEN clause up to the end of the statement, or until an ELSE clause is encountered. If the expression returns a FALSE value, execution of the statement continues with the directives following the ELSE clause (if you use it) or with the next statement. You would normally include a logical operator (such as an equals sign =, less-than symbol <, etc.) in the numeric expression, but you can use any numeric expression. All statements within an IF..THEN..ELSE structure exist on the same line. These statements can only span multiple lines if they are enclosed within curly brackets. A matched set of open/closed brackets must be provided for each set of directives. Missed brackets can cause unexpected results. Internally, when the system detects a { following the THEN clause it will continue execution up to the next } (if true) or skip forward to it (if false). The same holds true for the processing of the ELSE clause. You can imbed multiple levels of multiple line IF directives using curly brackets; however, it is important not to lose consistency. |
|||||||||||||||||||||||||||
| Using END_IF | An optional END_IF (or FI) clause can be used to terminate the current IF structure and/or to execute a common closing statement. This is particularly useful for separating ELSE clauses in a nested IF..THEN..ELSE structure. Once the statements that follow an END_IF clause are executed, control will fall through to the next line, or (if nested) to the preceding level of IF..THEN..ELSE. | |||||||||||||||||||||||||||
| See Also | END_IF End IF Directive. | |||||||||||||||||||||||||||
| Examples | Simple IF
Statement
|
|||||||||||||||||||||||||||
Compound IF
Statement:
|
||||||||||||||||||||||||||||
Multiple
Line IF
Statement.
|
||||||||||||||||||||||||||||