[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
DO CASE
DO CASE is a structured programming command that selects only one
course of action from a set of alternatives.
Syntax
DO CASE
CASE <condition>
<commands>
[CASE <condition>]
<commands>
[OTHERWISE]
<commands>
ENDCASE
Usage
ENDCASE terminates the DO CASE structure. Command pairs such as DO
CASE...ENDCASE, IF...ENDIF, and DO WHILE...ENDDO must be properly
nested within DO CASE. Nested DO CASEs are permitted. There are no
nesting limits within the DO CASE structure.
CASE <condition> sets up a conditional statement for evaluation. It is
a logical expression such as A=B or numvar<11. When <condition>
evaluates to logical True, all subsequent commands are carried out
until any one of the following commands is reached: another CASE,
OTHERWISE, or ENDCASE.
After one True CASE is found and its associated commands are processed,
no further CASE statements are evaluated. Program control will skip
immediately to the first command after ENDCASE. If no CASE statements
evaluate to True, and there is no OTHERWISE statement, the program
processes the first command following ENDCASE. OTHERWISE causes the
program to take an alternative path of action when all CASE statements
evaluate to False.
Note that like all other control structures, only the first three
characters of the END statement are significant.
Tips
In instances where only one of many conditions will evaluate to True,
or where only the first True instance is to be processed, the DO CASE
command is preferable to the IF command.
The CASE construction is often used when there are a small number of
exceptions to a condition. The CASE <condition> statements can
represent the exceptions, and the OTHERWISE statement the more common
situation.
See Also:
DO
DO WHILE
IF
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson