Compaq COBOL AAQ2G1FTK User Manual
Page 90
Developing Compaq COBOL Programs
1.5 Using Program Switches
1.5.1 Setting and Controlling Switches Internally
To set switches from within the image, define them in the SPECIAL-NAMES
paragraph of the ENVIRONMENT DIVISION and use the SET statement in
the PROCEDURE DIVISION to specify switches ON or OFF, as in the following
example:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
SWITCH 10 IS MY-SWITCH
ON IS SWITCH-ON
OFF IS SWITCH-OFF.
.
.
.
PROCEDURE DIVISION.
000-SET-SWITCH.
SET MY-SWITCH TO ON.
IF SWITCH-ON
THEN
DISPLAY "Switch 10 is on".
.
.
.
To change the status of internal switches during execution, turn them on or off
from within your program. However, be aware that this information is not saved
between runs of the program.
Refer to the Compaq COBOL Reference Manual for more information about
setting internal switches.
1.5.2 Setting and Controlling Switches Externally
On Tru64 UNIX systems, to set switches from outside the image, use the SETENV
command to change the status of program switches, as follows:
% setenv COBOL_SWITCHES "switch-list"
To remove switch settings:
% unsetenv COBOL_SWITCHES
To check switch settings, enter this command:
% printenv COBOL_SWITCHES
Shows switch settings.
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:
% setenv COBOL_SWITCHES "1,5,13"
Sets switches 1, 5, and 13 ON.
% setenv COBOL_SWITCHES "9,11,16"
Sets switches 9, 11, and 16 ON.
% setenv COBOL_SWITCHES " "
Sets all switches OFF.
♦
On OpenVMS Alpha systems, to set switches from outside the image or for a
process, use the DCL DEFINE or ASSIGN command to change the status of
program switches as follows:
$ DEFINE COB$SWITCHES "switch-list"
1–60 Developing Compaq COBOL Programs