Like DCL, ICL has a set of commands, functions and control structures which can be used to write powerful command files and procedures, both of which have the default extension ‘.ICL’. An important difference between command files and procedures is that command files run when loaded, whereas loading a procedure simply makes it available to run.
ICL syntax.
ICL syntax will generally appear familiar to the Fortran user although there are several important
distinctions. Perhaps the most striking difference involves variable type; this is not fixed but depends
on the current value of a variable. The example session below illustrates some of ICL’s capabilities.
The open bracket ‘{’ on an ICL command line begins a comment. Explanations of the ICL
commands below are shown enclosed in brackets {}
but the closing bracket is included only for
appearance.
ICL commands.
A selection of ICL commands were introduced in Section 17, i.e. LOAD, TASKS, DEFINE, KILL
and
DEFAULT
. A full list of the commands and their specifications can be examined by typing HELP
in
ICL.
ICL functions.
Several ICL functions (SQRT, UPCASE) are shown in the example session above. SNAME is a very
useful ICL function which concatenates a string with an integer (it is described here as it is used in the
procedure PLOTS later in this section). SNAME has two or three arguments, the first and second being
a string and an integer. The optional third argument gives the number of characters which the integer
part of the resultant string should occupy, for example: SNAME(’FIBRE’,2) returns FIBRE2
whereas
SNAME(’FIBRE’,2,3) returns FIBRE002
. A complete up-to-date list of functions can be viewed by
typing HELP FUNCTIONS
in ICL.
ICL control structures.
Two types of control structures are available within ICL; the loop structure, which can be compared to the Fortran DO loop, and the IF or conditional structure, which also resembles its Fortran equivalent. Three variants of the loop structure exist; an example of each is shown below. A BREAK statement can be used to pass control to the end of a LOOP; normally such a statement would be inside an IF structure. Also shown is an example IF structure.
ICL control structures can only be used in procedures. Both a LOOP and an IF control structure are used in the procedure PLOTS shown later in this section.
ICL command files.
ICL command files contain a set of ICL command lines and are activated by typing LOAD filename in ICL. For example, rather than typing the commands to define ADDNEW and REPDIM2 in each ICL session, the appropriate commands (as shown below) might be written to a file called MYCOM.ICL.
On entering ICL, loading this command file is analogous to activating a DCL command file.
Just as you probably have a LOGIN.COM file which executes every time you begin a VAX session, an
ICL login file can be set up which will execute each time you enter ICL. This is done by defining the
appropriate file as ICL_LOGIN
. For example, you might include the following line in your
LOGIN.COM:
ICL procedures.
ICL procedures are ideal for programming data-reduction sequences. An ICL procedure can use any
ICL commands (including user-defined commands) control structures, functions etc. As mentioned
above, loading a procedure does not cause it to run; it is simply made available for running whenever
the procedure name is typed. A procedure begins with the declaration PROC
procedurename and ends
with END PROC
. For example, the command file MYCOM.ICL above can be converted into a procedure
named MYPROC.ICL by inserting an initial line PROC MYPROC and a final line END PROC.
Running this procedure requires two steps: it is first loaded, after which it is run by typing the
procedure name as shown below. Subsequent runs do not require the procedure to be loaded
again.
Unlike command files, ICL procedures can have arguments as shown in the example below:
This is loaded and run as shown below:
The procedure below was written to produce CANON plots from seven data files each containing a
spectrum. These spectra had been extracted from a CCD image and named FIBRE01.SDF,
…FIBRE08.SDF
. One file, FIBRE06.SDF
is missing from the sequence, as this corresponded to a dud
fibre. The procedure uses KAPPA’s LINPLOT to produce and print the graphs on a CANON laser
printer (see SUN/95); it is therefore necessary to define the command LINPLOT (by typing
KAPPA) before running the procedure. Additional explanation is provided in the on-line file
ADAM_EXAMPLES:PLOTS.ICL
.