TSS/360: Command creation and user profiles
This week we'll look at some of the more advanced features of TSS/360: creating scripts that represent new user commands and customising your profile.
Command creation
Just to recap, when you compile a source code data set SOURCE.HWORLD
the system will create a binary object file that you can execute using RUN
HWORLD. But this is different from system commands that you can start
directly without the RUN, eg LINE? or CDS. What if you want to
just type HWORLD and it will run the program directly?
There is a command called BUILTIN that allows this - but this only
works for programs written in assembly language which call a specific
routine that processes command line parameters. Fortran programs, like
our hello world example, don't have this option.
But there is a way using the procedure definition facility. If you
type PROCDEF HWORLD it will start an editing session. Type RUN
HWORLD on the first line and _END on the second line to exit the
editor. You can now type HWORLD to invoke this.
procdef hworld 0000100 run hworld 0000200 _end hworld HELLO, WORLD!
In fact, this procedure definition facility is a scripting language, complete with parameters and control flow.
In the examples below I'll use the built-in command DISPLAY, which
you can access from the command line: it allows messages to be echoed
and simple calculations to be done.
display 'hello' HELLO display 21*2 42 display 1.5*3.0 +.45000000E+01
First, we'll define a procedure CUBE that will calculate the cube of
a number specified on the command line:
procdef cube 0000100 param x 0000200 display x*x*x 0000300 _end
This can then be run as follows:
cube 4 64 cube x=2 8
The language includes the IF statement to test logical conditions and
a GOTO statement that can branch to a label; however, the label can
only be defined after the GOTO statement, preventing backwards
branches and hence loops. A simple example:
procdef foobar 0000100 param $1 0000200 if '$1' = 'bar'; goto 'bar' 0000300 display 'foo' 0000400 'bar' display 'bar' 0000500 _end foobar xxx FOO BAR foobar bar BAR
You can even write procedures that make other procedures. The below
command make takes two parameters. Each time it is run, it will
create a new procedure under the name of the first parameter that will
print the second parameter.
procdef make 0000100 param $1,$2 0000200 default sysinx=e 0000300 procdef $1 0000400 display '$2' 0000500 __end 0000600 default sysinx=g 0000700 _end _ make qqq,www qqq WWW
Here variables are named $1 etc as a convention to show that named
keyword arguments are not used. The default sysinx tells the system
that its input comes from the program's input (e) rather than the
keyboard (g), allowing the inner procdef to work. The double underscore
on __end allows the break character to be escaped.
Procedures are stored in the SYSPRO component of USERLIB with each
procedure as its own region. They can be displayed and edited using
the text editor.
edit userlib(syspro) list CUBE 0000000 PROCDEF CUBE CUBE 0000100 PARAM X CUBE 0000200 DISPLAY X*X*X HWORLD 0000000 PROCDEF HWORLD HWORLD 0000100 RUN HWORLD ...
User profile
When you logon, you get a system default profile which you can then customise in several ways.
Default values
We saw DEFAULT used above to set the value of the implicit variable
SYSINX. It can also be used to set default values for command line
arguments. Say, for example, you are granting access to data sets
using PERMIT. Normally you give parameters for the data set, the
user id and the access type.
permit source.hworld,userid=tss,access=rw
Rather than typing the USERID and ACCESS parameters each time, you
could set defaults:
default access=rw default userid=tss
and then for the PERMIT command you'd just need to type
permit source.hworld
The defaults can be overridden by supplying them explicitly, so for example to revoke access
permit source.hworld,access=r
and the default itself can be removed by supplying a blank argument:
default access=
The interesting thing here is that these defaults apply to all
commands, ie if another command besides PERMIT had the ACCESS
keyword, this default would apply there as well.
Synonyms
Synonyms allow you to provide different names to commands or even keyword arguments. For example, if you do:
synonym dir=pc?
You can now type DIR and it will present a catalog listing by
running the PC? command.
Saving profile changes
The above commands only last for the duration of your logged in
session. To make them permanent, type PROFILE. This will save the
settings to the data set USERLIB(SYSPRX) where they will be read on
next logon.
Further reading
Full details on each command mentioned here can be found in the IBM Time Sharing System Command System User's Guide on Bitsavers.
Questions, corrections, comments
I welcome any questions or comments, and also especially any corrections if I have got something wrong. Please email me at rupert@timereshared.com and I will add it here and update the main text.