Setting Run-time Switches

You can specify switches in the following ways:

COBOL Programmable Switches

COBOL programmable switches are numbered from 0 to 8. Each can be set to "off" or "on" when your application is started. Their state can be read by your application at any time when it is running.

The COBOL programmable switches must be defined using a condition name in the special-names paragraph. For example:

 special-names.
     switch-0 is job-origin on status is us-office
                            off status is uk-office
  ...
 procedure division.
     evaluate job-origin
      when us-office...
      when uk-office...
  ...

Syntax for Setting Switches

The syntax for setting switches on the command line is:

({ {+|-|/}s }...)

To set switches using COBSW use the following operating system command:

COBSW={ {+|-|/}s }...
export COBSW

where:

{ | } Choose one of the items either side of the |.
{ }... You can repeat this item.
s A switch. It can be a digit, a letter (upper or lower case), or a letter followed by a digit in the range 0 through 7. A letter is equivalent to the same letter followed by the digit 0. For example B, B0 all refer to the same switch.
+ Sets the switch on.
- Sets the switch off.

Notes:

Examples

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

COBSW=+1+4

The following command loads the program myprog.int, myprog.gnt or myprog.so from the current directory (depending on the program search order) with programmable switches 5 and 7 on and switch 2 off.

cobrun -2+5-7+7 ./myprog

In the above example, note switch 7 is turned on, since the last setting of it (that is +7) is the one used. Switches 0, 1, 3, 4, 6 and 8, which are not specified, are off by default.

The following command loads the program Myprog with switches T on and O off:

cobrun (+T-O) ./myprog

関連項目