Developing Compaq COBOL Programs
1.5 Using Program Switches
The switch-list can contain up to 16 switches separated by commas. To set a
switch ON, specify it in the switch-list. A switch is OFF (the default) if you do
not specify it in the switch-list.
For example:
$ DEFINE COB$SWITCHES "1,5,13"
Sets switches 1, 5, and 13 ON.
$ DEFINE COB$SWITCHES "9,11,16"
Sets switches 9, 11, and 16 ON.
$ DEFINE COB$SWITCHES " "
Sets all switches OFF.
The order of evaluation for logical name assignments is image, process, group,
system. System and group assignments (including Compaq COBOL program
switch settings) continue until they are changed or deassigned. Process
assignments continue until they are changed, deassigned, or until the process
ends. Image assignments end when they are changed or when the image ends.
You should know the system and group assignments for COB$SWITCHES unless
you have defined them for your process or image. To check switch settings, enter
this command:
$ SHOW LOGICAL COB$SWITCHES
Use the DCL DEASSIGN command to remove the switch-setting logical name
from your process and reactivate the group or system logical name (if any):
$ DEASSIGN COB$SWITCHES
To change the status of external switches during execution, follow these steps:
1.
Interrupt the image with a STOP (literal-string) COBOL statement. (See the
Compaq COBOL Reference Manual for more information.)
2.
Use the DCL DEFINE command to change switch settings.
3.
Continue execution with the DCL CONTINUE command. Be sure not to force
the interrupted image to exit by entering a command that executes another
image.
For information about these DCL commands, see the OpenVMS DCL Dictionary.
♦
Following is a simple program that displays a message depending on the state
of the logical name COB$SWITCHES (on OpenVMS Alpha systems) or the
environment variable COBOL_SWITCHES (on Tru64 UNIX systems):
IDENTIFICATION DIVISION.
PROGRAM-ID. TSW.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
SWITCH 12 IS SW12 ON IS SW12-ON OFF IS SW12-OFF.
PROCEDURE DIVISION.
01-S.
DISPLAY "**TEST SWITCHES**".
IF SW12-ON
DISPLAY "SWITCH 12 IS ON".
IF SW12-OFF
DISPLAY "SWITCH 12 IS OFF".
DISPLAY "**END**".
STOP RUN.
END PROGRAM TSW.
Developing Compaq COBOL Programs 1–61