Sets the switches for the programs executing in the RunUnit
Namespace: MicroFocus.COBOL.RuntimeServices
Assembly: MicroFocus.COBOL.RuntimeServices (in MicroFocus.COBOL.RuntimeServices.dll) Version: 1.2.3.4
Syntax
Property Value
Type: StringImplements
IRunUnitSwitchesExceptions
| Exception | Condition |
|---|---|
| ArgumentException | If StopRun method has already been invoked. |
Examples
The following example shows a run unit (myRunUnit) being created and the COBOL class (switches) being called. When the class is called, it is implicitly instantiated and then run within the new run unit.
Finally the run unit is destroyed.
C#:
using MicroFocus.COBOL.RuntimeServices; public class UseSwitches { static void Main(string[] args) { RunUnit myRunUnit = new RunUnit(); try { myRunUnit.Switches = "+0+2+3+4+6+8-3"; myRunUnit.Call("switches"); } finally { myRunUnit.StopRun(); } } }
COBOL:
cobol
program-id. useSwitches as "useSwitches".
environment division.
configuration section.
repository.
class cls-RunUnit as
"MicroFocus.COBOL.RuntimeServices.RunUnit"
.
data division.
working-storage section.
01 myRunUnit object reference cls-RunUnit.
procedure division.
invoke cls-RunUnit "new" returning myRunUnit
set myRunUnit::"Switches" to "+0+2+3+6+8-3+4"
try
invoke myRunUnit::"Call"("switches")
finally
invoke myRunUnit::"StopRun"()
.
end program useSwitches.Where the called COBOL program is:
cobol
identification division.
program-id. switches.
environment division.
configuration section.
special-names.
switch-0 on status is sw-0,
switch-1 on status is sw-1,
switch-2 on status is sw-2,
switch-3 on status is sw-3,
switch-4 on status is sw-4,
switch-5 on status is sw-5,
switch-6 on status is sw-6,
switch-7 on status is sw-7,
switch-8 on status is sw-8.
procedure division.
if SW-0
display "0 = ON"
else
display "0 = OFF"
end-if
if SW-1
display "1 = ON"
else
display "1 = OFF"
end-if
if SW-2
display "2 = ON"
else
display "2 = OFF"
end-if
if SW-3
display "3 = ON"
else
display "3 = OFF"
end-if
if SW-4
display "4 = ON"
else
display "4 = OFF"
end-if
if SW-5
display "5 = ON"
else
display "5 = OFF"
end-if
if SW-6
display "6 = ON"
else
display "6 = OFF"
end-if
if SW-7
display "7 = ON"
else
display "7 = OFF"
end-if
if SW-8
display "8 = ON"
else
display "8 = OFF"
end-if
goback.See Also