SPL to HP C/XL Migration Guide (30231-90001)

6-5
|| |
| | Formats 2a and 4a deal with the case where |
||
step-val
is positive. Formats 2b and 4b |
| | handle the case where
step-val
is negative. |
| | There is no easy way to combine the |
| | formats. |
|| |
---------------------------------------------------------------------------------------------
In HP C/XL, the three expressions can actually contain multiple
expressions, separated by commas. The last or right-most becomes the
value of the expression. This is the method used to solve the SPL "*"
alternative, in formats 3 and 4. An arbitrary variable,
flag
is set to
1. Since
flag
is true on the first pass, it forces the execution of
loop-statement
. On subsequent passes, it is 0 or false, so the normal
end testing takes over.
Table 6-8. FOR Statement Examples
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| FOR I:=ABC STEP 1 UNTIL 99 | for ( I = ABC ; I <= 99 ; I++ ) |
| DO A(I):=B(I)-X; | A[I] = B[I]-X; |
| | |
| | |
| FOR * I:=ABC STEP -1 UNTIL 0 | for ( ONCE = 1 , I = ABC ; |
| DO A(I):=B(I)-X; | ONCE || I >= 0 ; |
| | ONCE=0 , I-- ) |
| | A[I] = B[I]-X; |
| | |
---------------------------------------------------------------------------------------------
The SPL FOR * construct may also be easily emulated by an HP C/XL
do-while statement, as illustrated by the following statements:
I = ABC ;
do A[I] = B[I]-X ; while (--I >= 0);
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. |