Sample System Procedures for Batch Execution

To extend the previous example a little further, suppose you wanted to process source files in languages other than the assembler language. You want, also, for any user to be able to use this exec. You might have a separate exec file for each language and an exec to control the submission of the job. Figure 1 shows the controlling file and BATCH EXEC, and Figure 2 shows the language file and ASSEMBLE EXEC.
Figure 1. BATCH EXEC
/* This exec submits assemblies/compilations to CMS Batch
     - Punch batch job card
     - Call appropriate language exec to punch executable commands */
 
    arg accnt filename language
    if language = ''
      then do
        say 'Correct form is: BATCH accnt filename language'
        exit 100
      end
    punch = 'EXECIO 1 PUNCH (STRING'
    trace errors
    signal on error
    'CP SPOOL D CONT TO BATCHCMS'
    punch '/JOB' Userid() accnt filename
    punch 'CP LINK' Userid() '191 291 RR SECRET'
    punch 'ACCESS 291 B/A'
    'EXEC' language filename Userid()
    punch 'RELEASE 291'
    punch 'CP DETACH 291'
    punch '/*'
    'CP SPOOL D NOCONT CLOSE'
    exit
    Error: exit rc
Figure 2. ASSEMBLE EXEC
/* Correct form is : ASSEMBLE fname userid
     Punch commands to:
       - Invoke CMS assembler
       - Return text deck to caller        */
 
    arg fname userid
    signal on error
    trace errors
    punch = 'EXECIO 1 PUNCH (STRING'
    punch 'GLOBAL MACLIB UPLIB DMSGPI OSMACRO'
    punch 'CP MSG' userid 'Asmbling' fname
    punch 'ASSEMBLE' fname '(PRINT NOTERM)'
    punch 'CP MSG' userid 'Assembly done'
    punch 'CP SPOOL D TO' userid 'NOCONT'
    punch 'PUNCH' fname 'TEXT A1'
    punch 'CP CLOSE D'
    punch 'CP SPOOL D OFF'
    exit
    Error: exit rc
Suppose FAY (user ID = FAY) invokes the BATCH EXEC by issuing the following command:
batch 1111 payroll assemble
The BATCHCMS virtual machine's reader should contain the following statements (in the same general form as a FIFO console stack):
/JOB FAY 1111 PAYROLL
CP LINK FAY 191 291 RR SECRET
ACCESS 291 B/A
GLOBAL MACLIB UPLIB DMSGPI OSMACRO
CP MSG FAY Asmbling PAYROLL
ASSEMBLE PAYROLL (PRINT NOTERM)
CP MSG FAY Assembly done
CP SPOOL D TO FAY NOCONT
PUNCH PAYROLL TEXT A1
CP CLOSE D
CP SPOOL D OFF
RELEASE 291
CP DETACH 291
/*
When the batch facility executes this job, the commands are executed as you see them: if you are logged on, you receive, in addition to the usual messages that the batch facility issues, those messages that are included in the exec.