SPL to HP C/XL Migration Guide (30231-90001)
6-7
CASE Statement
Table 6-11. CASE Statement
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
|
case-statement
: |
switch-statement
: |
| | |
| CASE [*]
index
OF | switch (
index
) |
| | |
| BEGIN |
"
{
"
|
| | |
|
statement0
; | case 0:
statement0
break ; |
| | |
|
statement1
| case 1:
statement1
break ; |
| | |
| [;...][;] | [...] |
| | |
| END | [default:
exception-statement
] |
| | |
||
"
}
"
|
| | |
---------------------------------------------------------------------------------------------
| | |
| The statements in the BEGIN-END clause are | The statements in the { } clause are |
| implicitly numbered from 0. They may be | explicitly numbered with case
number
|
| compound statements. | labels.
number
may be any integer |
| | constant, including a character constant. |
| | There may be multiple simple, structured, |
| | or compound statements between labels. |
| | |
| | The break statement is required to emulate |
| | the operation of the SPL CASE statement, |
| | except if the SPL statement contains a GOTO |
| | statement. |
| | |
---------------------------------------------------------------------------------------------
| | |
|
index
is evaluated and the corresponding |
index
is evaluated and execution transfers |
| statement in the BEGIN-END clause is | to the case label with the corresponding |
| executed. Then execution drops through to |
number
. Statements are executed in |
| the statement after the CASE statement. | sequential order from that point until |
| | (1) the end of the { } clause is reached, |
| | (2) a break statement is executed, or |
| | (3) a goto statement is executed. |
| | If (1) or (2) occurs, execution drops |
| | through to the statement after the switch |
| | statement. |
| | If (3) occurs, execution continues at the |
| | label specified. |
| | |
---------------------------------------------------------------------------------------------
| | |
| If
index
is out-of-range, execution simply | The optional default label can be used to |
| drops through to the statement after the | trap out-of-range index values. If it is |
| CASE statement. | omitted, execution simply drops through to |
| | the statement after the switch statement. |
| | |
---------------------------------------------------------------------------------------------
| | |
| The "*" option turns off bounds checking. | No equivalent. Just delete the "*". |
| | |
---------------------------------------------------------------------------------------------