IF Statement [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation
SPL to HP C/XL Migration Guide
IF Statement
Table 6-9. IF Statement
----------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
----------------------------------------------------------------------------------------------
| | |
| if-statement | if-statement: |
| | |
| IF condition-clause THEN true-statement | if ( condition-clause ) true-statement |
| | |
| [ELSE false-statement] | [else false-statement] |
| | |
----------------------------------------------------------------------------------------------
| | |
| If condition-clause is true, true-statement | Same as SPL. |
| is executed. If it is false, and the ELSE | |
| clause is present, else-statement is | |
| executed; if the ELSE clause is omitted, | |
| execution falls through to the statement | |
| after true-statement. | |
| | |
----------------------------------------------------------------------------------------------
| | |
| If the ELSE clause is present, | Regardless of whether the else clause is |
| true-statement must not end with a | present, a simple true-statement must end |
| semicolon. | with a semicolon. (The terminating "}" of |
| | a compound statement implies the |
| | semicolon.) |
| | |
| | Note that the condition-clause is enclosed |
| | in parentheses and that THEN is deleted. |
| | |
----------------------------------------------------------------------------------------------
Table 6-10. IF Statement Examples
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| IF X<0 THEN Y:=0; | if (X<0) Y=0; |
| | |
| IF X>0 THEN | if (X>0) |
| BEGIN | { |
| Y:=0; | Y=0; |
| T:=V+10; | T=V+10; |
| END; | } |
| | |
| IF X=0 THEN X:=21 | if (X==0) X=21; |
| ELSE | else |
| BEGIN | { |
| Y:=0; | Y=0; |
| T:=V+10; | T=V+10; |
| END; | } |
| | |
---------------------------------------------------------------------------------------------
MPE/iX 5.0 Documentation