Problem:
Setting a external runtime switches that can be used within COBOL applications.
Resolution:
The COBOL program would be coded as follows:
IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
switch-0 ON is test-switch-0
switch-1 ON is test-switch-1
switch-2 ON is test-switch-2.
DATA DIVISION.
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
100-process.
if test-switch-0
display "*** Switch-0 is set".
if test-switch-1
display "*** Switch-1 is set".
iftest-switch-2
display "*** Switch-2 is set".
exit program.
stop run.
You can then set COBSW environment variable (export COBSW= 1 2) or
You can then run your program using - cobrun 0 <pgm-name>
cobrun 1 <pgm-name>
cobrun 2 <pgm-name>
or any combination cobrun 0 2 <pgm-name>
In the Special-Names paragraph you can also specify if the switch is "off" (switch-3 OFF is test-switch-3. You can then - cobrun -3 <pgm-name> or set COBSW=-3