Wednesday, July 29, 2015

The BATCH utility

In my last post, I talked in some depth about how to build a multi-module Fortran program, and then at the end lamented a little bit about the lack of any way to automate builds.  Well, as it turns out, I was wrong!  There is an OS/8 utility called BATCH that allows you to do this.  In my first pass through the OS/8 Handbook, I came across this utility, but since they really describe it as a batch processing utility, which isn't anything I'm really doing, I skipped over it and kind of forgot about it.

But after writing my post yesterday, I recalled that it was there and wondered if it could be used to automate builds.  And, sure, enough it can - quite easily, in fact.  It's not without its own quirks and pitfalls, but it is a pretty nice little utility that pretty much allows you to execute any set of commands.

To use this, you have to create a text file with your commands.  There are a few tricks, but it's generally straightforward.  First, the file has to be on a permanent device.  So a hard disk (RK device) is acceptable, but a floppy (RX) is not.  But on my system, the second partition, RKB0, wasn't acceptable either.  It had to be on RKA0.  Since I'm developing my source on a floppy image, it's a little annoying that the equivalent of my make file has to be on the main hard drive, but c'est la vie.  There may be a way around this, but for now it's acceptable.

Using the BATCH utility is pretty simple.  First, come up with your build script (I named mine simply BUILD), such as this one for my little test program:

$JOB
/ CLEAN EXISTING FILES
.DEL RXA0:TEST.RL
.DEL RXA0:TEST.LD
/ COMPILE
.R F4
*RXA0:TEST<RXA0:TEST
/ LOAD
.R LOAD
*RXA0:TEST<RXA0:TEST
*$
/ EXECUTE
.R FRTS
*<RXA0:TEST$
$END

If you're already familiar with OS/8, or you read my last post, then much of the above is already familiar.  Also, I assume $JOB and $END are pretty self-explanatory.  As you might also infer from the above, lines that start with a slash are comments.  Everything else is pretty much the same OS/8 commands that you should recognize.  The only two things to note is that you must precede each line with a '.' or '*' as the Keyboard Monitor or Command Decoder would do if you were entering the commands interactively.  So when you run a program, it is ".R <program>", not just "R <program>".  The parameters would be preceded by a "*".  And, finally, when you need an ALTMODE character (ESC on modern keyboards), you just use a $, i.e., Shift-4.

Calling this file is even easier.  The CCL command, SUBMIT, calls the BATCH utility, so you can execute your batch file by:


.SUBMIT BUILD

Of course, this still isn't a proper build system as we're used to now.  There's no conditional compilation based on what's changed and no error checking.  So if the compile fails, for example, it will still perform the LOAD and FRTS commands.  But this is still much better than the alternative, typing in each command by hand every time.

No comments: