While it is possible to compile and/or load a B program in batch, the simplest way to use B in batch is to prepare a batch-oriented load module in TSS. This is done by specifying the +Batch option in the B command, like so:
b +batch /prog.b h=/hstarThe +Batch option causes the B run command to load the program using the batch run-time library. The hstar file must be a permanent file. To make the program run in batch, use a $ PROGRAM card with the name of the load module (the default is OBJECT) and a PRMFL card with a file code of **, as in
$ IDENT userid,banner $ PROGRAM OBJECT $ PRMFL **,r,r,userid/hstar $ ENDJOB
Almost every feature normally supplied by the B I/O package in TSS also works in batch. However, do not include any calls to "drl.drl". You can make GCOS batch system calls (MMEs) by using the B function "mme.mme" (see expl b lib mme.mme).
Just like TSS B programs, batch B programs try to read and break up a command line. Batch B does this by reading from file code CZ. It also sets up the default read unit by attempting to open file code I*. If file code CZ is not present, ARGC is set to zero. If file code I* is not present, unit zero is NOT opened, and will probably be used by the first file opened by the user program. You may redirect I/O on the CZ command line, just as in TSS.
Since file code CZ is opened, read, and then closed again during command line processing, the unparsed command line cannot be retrieved with a "reread(-5); getstr(-5,str);" sequence. Instead, you must reopen file code CZ.
The default write unit (unit 1) is set up to write to file code P*. Normally, P* is assigned to SYSOUT and the B run-time package writes to it in media three print BCD, with a report code of 72. To write to SYSOUT in ASCII, use
extrn wr.mc7; ... set.mc( 1, 0772 )where 07 is the media code for ASCII (use 03 for BCD) and 72 is the report code.
To access a file according to a file code, the OPEN and ACC.FIL recognize the convention FC*xx, which is interpreted as a request to use file code XX.
If file code P* is directed to SYSOUT, it may be opened several times, each with a different report code. That way, SYSOUT separates the output and directs it to the printer as a series of reports. For example,
open( 4, "fc**p**", "w", 0304); open( 5, "fc**p**", "w", 0305);opens units 4 and 5 as output units which write to file code P* in media 3 format, using report codes 4 and 5 respectively. (Note that the "*" character must be doubled inside B strings.)
If there is some doubt as to file code P* being assigned to SYSOUT and several report codes are desired, then you must call SET.RC every time you wish to change report codes. This is similar to the way you change the default read or write unit to switch between files.
A batch B user has available the traditional techniques involving load maps, printer dumps, and debugging printouts to trace flow of control. However, post-mortem debugging of batch B programs is possible using BOFF if you supply a file with a file code of PM in the activity. If a fault occurs, the program gets control for wrap-up procedures; at that time, a memory dump in "abrt" file format is written to file code PM if PM has been defined. The batch wrap-up procedure will attempt to grow the abort file if necessary. This file may then be examined interactively with the BOFF "Abort" subcommand to determine the cause of the abort. We recommend that you load the program in TSS if possible, since the TSS loader includes symbol tables in the hstar and these make it much easier to examine the abort file.
Bear in mind that it is often possible to debug a B program in TSS, then simply reload the program for batch when you are ready to produce a final copy.
Copyright © 2000, Thinkage Ltd.