COBOL Manual for TNS and TNS/R Programs
Procedure Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
8-62
Simple Conditions
Switch-Status Conditions
A switch-status condition determines whether an external switch is on or off. The
particular switch and the ON or OFF value associated with the condition must be
named in the SPECIAL-NAMES paragraph of the Environment Division.
Usage Considerations:
•
TRUE Value
The result of the test is TRUE if the switch is set to the position corresponding to
the one identified by the condition-name; otherwise, the result of the test is FALSE.
•
Setting External Switches
Set external switch value by using the PARAM command of the command
interpreter (see SPECIAL-NAMES Paragraph) or by the SET statement (see SET).
Example 8-12. Conditional Variables
WORKING-STORAGE SECTION.
01 ZIP-CODE.
03 ZIP-FIRST-3 PICTURE 999.
...
88 NEW-YORK VALUE IS 090 THRU 098,
100 THRU 149.
88 PENNSYLVANIA VALUE IS 150 THRU 196.
...
PROCEDURE DIVISION.
...
ELSE IF NEW-YORK MOVE "NY" TO STATE-FROM-ZIP
ELSE IF PENNSYLVANIA MOVE "PA" TO STATE-FROM-ZIP
...
IF STATE-INPUT NOT = STATE-FROM-ZIP
PERFORM QUERY-ZIP-OR-STATE-CORRECTION.
Example 8-13. External Switches
SPECIAL-NAMES.
SWITCH-1 IS IN-SWITCH ON STATUS IS TAPE-INPUT
OFF STATUS IS DISK-INPUT
SWITCH-2 IS OUT-SWITCH ON STATUS IS TAPE-OUTPUT
OFF STATUS IS DISK-OUTPUT.
...
PROCEDURE DIVISION.
...
IF TAPE-INPUT OPEN INPUT TAPE-SOURCE
ELSE OPEN INPUT DISK-SOURCE.
IF TAPE-OUTPUT OPEN OUTPUT TAPE-SINK
ELSE OPEN OUTPUT DISK-SINK.
...