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
Unix side).
Simple sequences
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
command.
- The file header keywords and the
XAS environment
will take care of exchanging information between one program and the next.
Parametric sequences
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
sequence containing
XAS commands
(and invocation of
command files )
in which some runstring or command file arguments are left "blank" and will therefore be
prompted interactively.
Procedure scripts
One will need to write a proper script under two conditions :
- one needs programming facilities like branching (IF statements) or manipulation
of shell variables
- one need to interact with
XAS environment variables
Programming is left to the facilities of the user's favourite shell and is not of
our concern here.
Coming to the interaction of the XAS and system variables one shall instead note what follows.
- 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
xasset
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
XAS_ECHO
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
ttyp1_poseidon.environment.
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.
sax.iasf-milano.inaf.it/Xashelp/xasprog.4.html
:: original creation 2002 Sep 04 17:38:28 CEST ::
last edit 2002 Sep 04 17:38:28 CEST