Sample CMS EXEC Language Program
The following CMS EXEC program, called RUNCOB2 EXEC, compiles, loads, and executes
a VS COBOL II source file:
* RUNCOB2 EXEC *
&CONTROL OFF NOMSG
&IF &INDEX LT 1 &GOTO -ERR1
COBOL2 &1
&IF &RETCODE NE 0 &EXIT
GLOBAL TXTLIB VSC2LTXT CMSLIB
&IF &RETCODE NE 0 &EXIT
LOAD &1 (START
&IF &RETCODE NE 0 &EXIT
&TYPE RUNCOB2 EXEC FINISHED
&EXIT
-ERR1
&TYPE PROGRAM NAME NOT GIVEN
&EXITRUNCOB2 EXEC works as follows:
- The control statement
&CONTROLsets the type of execution information displayed at the console. No execution messages or return codes are to be displayed here. - The control statement
&INDEXis a special variable that contains the number of arguments entered by the caller. If no arguments are supplied, execution goes to label-ERR1. COBOL2 &1compiles the source program, specified by&1. If theCOBOL2command does not complete successfully,&RETCODEis nonzero and&EXITis processed causing an immediate exit from the exec. The special variable&RETCODEcontains the return code from the most recently executed CMS command. If&RETCODEis zero, the source program compiled successfully.- If the
GLOBALcommand fails,&RETCODEis nonzero and&EXITis processed causing an immediate exit from the exec. If&RETCODEis zero, the TXTLIBs are successfully found and identified. LOAD &1 (STARTloads the compiled program and executes it. If theLOADcommand fails,&RETCODEis nonzero and&EXITis processed causing an immediate exit from the exec. If&RETCODEis zero, the program was loaded and executed and theRUNCOB2 EXEC FINISHEDmessage is displayed.- If too few arguments are supplied, execution is routed to the
label
-ERR1, where the warning message is typed. No&EXITis required here, because processing ends at the end of the exec.
For information on the formats for the CMS EXEC control statements, use the HELP facility by using the HELP command.