2.4 XAS procedures
XAS is not Yet Another Scripting Language and does not explicitly
supports the writing of procedure scripts, but defers this to the facilities
provided by the various operating systems (e.g. shell scripts or DCL command
files), with which the user is perhaps more familiar.
We give here only a brief tutorial on the possibilities of assembling sequences
of XAS commands to perform repetitive tasks (with particular emphasis on the
If one needs to execute often a standard sequence of XAS commands to perform a
standard reduction, using always the same standard file names, without need
to pass any argument, and without the need of "branching" (no IF statements
depending on previous results), it is sufficient
- to write into a file the sequence of XAS commands
- to invoke the file in the current process, without the need to make it
an executable script, e.g. in Unix C shell using the source
- The file header keywords and the
will take care of exchanging information between one program and the next.
By "parametric" sequence we mean a standard sequence of XAS commands used to perform a
standard reduction, without the need of "branching" (no IF statements
depending on previous results), but which requires some arguments (e.g. file names
or numeric parameters).
This can be arranged as an executable shell script with arguments, or even as a "source" file
by setting the arguments in specific shell environment variables. The same concepts
given above for simple sequences are valid here too, provided one does not need to access
the XAS environment
at shell level.
Note also that, if one wishes to supply some arguments interactively, one can use a simple
(and invocation of
command files )
in which some runstring or command file arguments are left "blank" and will therefore be
One will need to write a proper script under two conditions :
Programming is left to the facilities of the user's favourite shell and is not of
our concern here.
- one needs programming facilities like branching (IF statements) or manipulation
of shell variables
- one need to interact with
XAS environment variables
Coming to the interaction of the XAS and system variables one shall instead note what follows.
One can, if desired, access directly the content of the file where the environment is
stored. This file is in the user login directory, and has a name linked to the current
terminal name (e.g. ttyp1) and to the hostname (e.g. poseidon), like
- XAS environment variables are usually used to contain setup information arranged by
the user. There are however cases in which they are set by XAS programs. In particular
there is a result variable intended to pass
back program results.
- The XAS and system environment shall be regarded as two disjoinct subsets of a larger
environment : each "half" can be accessed as "read-write" from either XAS or the shell,
and as "read-only" from the other.
- use only
to set XAS variables.
- use only shell commands (e.g. set, setenv) to set system environment variables
- In particular if a XAS environment variable is not set, but
a system variable of the same name exists, XAS program are able to use its value.
- Conversely in principle all XAS environment variable are
accessible to the system shells as system environment variables with
uppercase names prefixed by XAS_.
E.g. the XAS environment variable ECHO will be known to the system as
One may then use also a command of the following form to copy back a XAS environment
variable into a shell variable :
set fotdirname = `grep FOTDIR ~/ttyp1_poseidon.environment | cut -f2 -d'='`
Note also that the environment files remain there after you log off, but are in general
cleared when you log in again and issue your first XAS command in the new session. If you
wish to continue preserving the last session XAS environment, just touch the
environment file before issuing ANY XAS command.
A similar effect is obtained if you copy or rename the environment file of a session into another.