Setting Run-time Switches

Restriction: These switches are supported for native COBOL only.

You can specify programmable and general run-time switches using the following methods:

Using environment variables
Use the environment variables COBSW and OOSW (for switches for object-oriented programs) to set or override the switch values when the application is started.
Note: We recommend that for switches affecting file handling, you do not use COBSW, but edit the file handler configuration file (extfh.cfg) instead.

The following command sets the programmable switches 1 and 4 on, and all the others (2, 3, 5-8) are off by default:

export COBSW=+1+4
On the command line
Specify switches on the command line when you start the application. Switch set here take precedence over those in the environment variable (COBSW).

In the following example, the command loads the program myprog with programmable switches 5 and 7 on and switch 2 off, and all the others (0, 1, 3, 4, 6 and 8) are off by default. Note that switch 7 is turned on, since the last setting of it (that is +7) is the one used.

cobrun -2+5-7+7 ./myprog.int
Note: On UNIX platforms, you can only set switches on the command line when using the cobrun command, and so limits the use to .int, .gnt, or .so files.