🛠️ P3/COBOL 25.1.0-SNAPSHOT is available for preview.
User Guide
Switches

Switches

P3/COBOL implements environmental switches accessible by the COBOL application using the standard phrases in the SPECIAL NAMES paragraph in the CONFIGURATION SECTION.

Switch Names

The switch names available to the COBOL programmer are:

  • SWITCH-0 through SWITCH-8, and
  • USPI-0 through USPI-7
  • TSW-0 through TSW-31
  • USW-0 through USW-31
  • SYSTEM-SHUTDOWN

These switch settings are maintained in the P3/COBOL Run Unit and can be set by the runtime.p3c configuration file, as well as dynamically manipulated by the COBOL program according to the standard rules regarding switches (i.e., mnemonic names and conditional variables).

Setting Switches

To set switches in the configuration file that will be visible to all programs running under the configured run unit, use the following entry:

runtime.p3c
<switch-settings>
    <switch>
        <name>switch-name</name>
        <setting>switch_setting</setting>
    </switch>
</switch-settings>

Where:

{switch-name} is SWITCH-1 ... SWITCH-8 or USPI-0 ... USPI-7

{switch-setting} is:

Switch SettingDescription
ONInitial state of switch is set to ON
OFFInitial state is switch set to OFF
WIRED_ONThe switch is set to ON and made immutable
WIRED_OFFThe switch is set to OFF and made immutable
NCThe switch value is not set until programmatically set
💡

WIRED_ON and WIRED_OFF determine the immutable state of the switch
(the switch cannot be changed by the application program)

This is an example configuration file that sets switches.

runtime.p3c
<p3-runtime-options>
    <program-package>programs</program-package>
    <byte-order>BIG_ENDIAN</byte-order>
    <switch-setting>
        <switch>
            <name>SWITCH_1</name>
            <setting>ON</setting>
        </switch>
        <switch>
            <name>SWITCH_3</name>
            <setting>WIRED_OFF</setting>
        </switch>
    </switch-setting>
</p3-runtime-options>

In this case, SWITCH-1 is set ON initially, and can be changed by the program and SWITCH-3 is set OFF and cannot be changed by the program.