BATCH - how to use Pascal in batch.


This explain file discusses the preparation of programs to be run in batch, some basic batch JCL and facilities, command line processing, batch-specific file access conventions, and batch aborts.

Compiling in Batch:

The following example will compile and run a Pascal program in batch.

$    ident   userid
$    lowload
$    option  nofcb
$    program pascal,lstin,debug
$    select  pascal/compile
<Insert Program here>
$    select  pascal/execute
<insert data here>
$    endjob

The select file COMPILE must immediately follow the $PROGRAM PASCAL card. The source may be included in the deck, or may be accessed under file code S*. Listing and error messages are directed to P*. The select file EXECUTE contains a $EXECUTE card and references to the standard Pascal libraries. The standard libraries are accessed as file codes PL and CL; any user libraries should use different file codes. Data may be included in the deck or may be accessed under file code I*.

The load module may of course be saved on file code H*, using the GLOAD SAVE/<NAME> option. For a full list of the options to the Pascal compiler, see "expl pascal batch options".

Compiling for Batch in TSS:

To prepare a Pascal program in TSS to be run in batch, compile it with the "+Batch" option of the Pascal command and use the "Hstar=filename" option to save the load module in a permanent file.

Basic Batch Facilities and Use:

The minimal JCL needed to run a saved Pascal program in batch looks like this.

$      ident    userid,banner
$      program  object
$      prmfl    **,r,r,userid/hstarfile
$      endjob

"Object" is the default program name set by the Pascal command; if you want to use a more meaningful name, specify it using the GLOAD "save/name" option or the TSS Pascal "Name=pgmname" option. "Userid/hstarfile" represents the full name of the file in which you saved the load module prepared by the PASCAL command.

Output (using the predefined file variable "output") is directed to file code P*. Run-time error messages also go to P*. If P* is assigned to SYSOUT, output is converted to BCD print image.

Output files may only be written to SYSOUT, tape, or disk. Files of "text" are written in Media 6 ASCII. Binary files (all other types) are written in Media 1 binary.

Input using the file variable "input" is normally taken from file code I*. If file code I* is not present, it is an error to read from "input". Data for I* may be supplied as usual, either by including lines of data in the JCL or else by using a $PRMFL card for I*.

Input may by taken only from tape or disk files. For information on how Pascal handles various media codes, see "expl pascal media".

Command Line Processing:

In order to provide compatibility with TSS, batch Pascal programs will interpret command lines provided as file code CZ, if present. Only the first line of file code CZ is of any significance.

As in TSS, you may specify arguments on the command line that "redirect" input/output on the predefined I/O units. For example, if you had the JCL

$      ident    userid,banner
$      program  object
$      prmfl    **,r,r,userid/.h
$      data     cz
x <userid/infile >>userid/outfile
$      endjob

Input would be taken from file "infile" instead of from file code I*, and output would be appended to file "outfile" instead of being written to P*. Run-time error messages always go to P*.

File Access Conventions:

Because of differences between batch and TSS, there is a change in the convention used when a file opened for writing is found not to exist, and there is a convention to permit opening by file code, rather than by file name.

In the first case, suppose you made the call

openf( f, 'outfile', 'w' );

and file "outfile" did not exist. In TSS, the next step would be to attempt to define a temporary file called "outfile"; in batch, the I/O package will attempt to create a quick-access permanent file of that name under the userid the job was running under.

In order to refer to batch file codes (which one may pass from one activity to another), you can use a name of the form "fc*xx" where "xx" is the file code you wish to refer to. Since there is a "*" in the name, this cannot possibly refer to a quick access permanent file, so there is no conflict. To run the same program in TSS, the desired file may be accessed under an altname of "fc*xx" before running the program. For instance, to open file code OT for writing, you would say

openf( f, 'fc*ot', 'w' );

If you use this convention to access a file code for writing, and it turns out the file code does not exist, the I/O package will use MME GEMORE to create a temporary file (with the disposition set to be dropped at the end of the current activity). However, it is an error to attempt to open a file code for reading if the file code does not exist.


Most of the time, the occurrence of an error at run-time will be signaled by an error message sent to SYSOUT. However, there are two cases that result in a MME GEBORT. If the memory allocator (called by "New") is denied in an attempt to increase memory size, it aborts with "0K" status. If a stack overflow is detected, the program is aborted with "NS" status.

If you supply a file code called PM in your JCL and some kind of abort occurs, then when wrapup is called the run-time package will attempt to dump the contents of memory in TSS "abrt" file format. File code PM should be associated with a permanent disk file.

Empty Files and Bit Buckets:

If you wish to pass an empty file as input to a Pascal program, use a $DATA FC,NULL control card to create such a file. If you wish to discard all the output from a given file code, use a $FILE FC,NULL. Do not attempt to use a $FILE FC,NULL for an input file code. For example

$    userid  xxx
$    ident   xxx
$    program object
$    prmfl   **,r,r,xxx/.h
$    data    i*,null
$    file    ot,null
$    endjob

The program would find "eof(input)" to be true immediately, and if it opened file code OT for output (e.g. openf(otfile, 'fc*ot', 'w')), all output written to that file would be discarded.

See Also:

expl pascal batch options

Copyright © 1996, Thinkage Ltd.