Chapter 5
ICL — Interactive Command Language

 5.1 Introduction
 5.2 Starting and stopping ICL
 5.3 Modes
 5.4 Statements
 5.5 Direct statements
 5.6 Expressions

5.1 Introduction

ICL is the most commonly used ADAM command language. It is designed to provide a programmable user interface to an astronomical data-reduction or data-acquisition system. In some ways, ICL is similar to a high level programming language such as Fortran or Pascal, but it has some important differences:

The definitive reference manual and user’s guide is SG/5. The language is summarised in Chapter 19. ICL also has an on-line Help system — simply type HELP.

5.2 Starting and stopping ICL

ICL is started by typing:

    $ ICL

(Always remember that you must previously have executed SSC:LOGIN and ADAMSTART.)

ICL is stopped by issuing the EXIT command:


If things are hopeless you can, of course, abandon ship by typing Ctrl/Y.

5.3 Modes

ICL can be used in two different modes:

In Direct Mode, statements are executed immediately after they are typed in. In Procedure Mode, statements are first entered into a procedure, and subsequently executed by running that procedure. Another difference between the modes is that Control Statements (see below) can only be executed in Procedure Mode.

5.4 Statements

The statements of the language can be grouped into two sets:

Direct statements are executed immediately and can be entered in either mode. Control statements affect the order in which statements are executed and can only be executed in Procedure mode. You can also enter Comments which are lines whose first non-blank character is ‘{’. Comments are ignored by the language interpreter. If desired, they can be terminated by ‘}’, but this isn’t necessary and is a matter of taste. Here is an example of a comment:

    { This is a comment

Although comments can be entered in Direct mode, their real purpose is to document procedures written in Procedure mode.

When entering statements in ICL, all the normal command line editing facilities available in DCL may be used. The Up arrow or ctrl/B keys may be used to recall previous commands, and the Down arrow key will step to the next command. Any command back to the start of the ICL session may be recalled.

A command may take more than one line. A tilde (~) symbol at the end of a line is used to indicate that the command continues on the next line.

5.5 Direct statements

There are three types of direct statements:

Immediate Statement:

This is used to make ICL do simple calculations. It consists of an equals sign (=) followed by an expression, and causes the value of the expression to be printed on the terminal. For example:

    ICL> =1+2+3  
    ICL> =SQRT(2)  

Assignment Statement:

This is exactly the same as the Fortran assignment statement and is used to assign a value to an ICL variable. For example:

    ICL> PI=3.1415926  
    ICL> =2*pi  

Note that the case of letters doesn’t matter. ‘PI’ and ‘pi’ are the same variable. In practice, names like ‘PI’ are the names of HDS objects which store the constant values.


A command consists of a command name followed (optionally) by one or more parameter specifications:

command_name [parameter_specification] …

The parameter specifications may be separated by commas, or by one or more spaces. The forms that parameters can take are described in Chapter 8. Here are some examples of commands:

    PRINT Single Root is (-C/B)  
    QUADRATIC 7.2,18,4.6  
    TESTR 5.8

Commands are a very important part of ICL and several types exist. You can’t tell which type a command is just by looking at it; you have to know how it is defined. Commands are described in more detail in Chapter 6.

All three types of direct statement make use of expressions. These are described next.

5.6 Expressions

One of the basic syntactical units of the ICL language is the Expression. Expressions are built up by operating on values using operators:

VALUE operator VALUE operator VALUE …

Here are some examples of expressions:


The value of an expression belongs to one of the following four types:

The two constituents of expressions — value and operator — will now be considered in more detail:

— A value can be represented in three ways:

Real and Integer constants are represented by numbers written in the same formats that are accepted in Fortran. Integer constants may also be entered in binary, octal, or hexadecimal format by preceeding the value with %B, %O, or %X respectively.

Logical constants are written as TRUE or FALSE. Note that they are not delimited by decimal points as in Fortran.

String constants consist of any sequence of characters enclosed in either single or double quotes. Two consecutive quote symbols in a string are used to represent a single quote. String constants are the one place in ICL where the case of letters is significant.

Here are some examples of constants:

    Real:          1.234E-5              3.14159  
    Integer:       123      %B100110     %O377      %Xffff  
    Logical:       TRUE     FALSE  
    String:        ’This is a string’    "So is this"      ’’

The last example defines a string of zero length (valid in ICL, but not in Fortran).


Variables are represented by names composed of characters which may be letters, digits, or the underscore character (_). The first character must be a letter. The first 15 characters of a variable name are significant.

An important difference between ICL and Fortran is in the handling of variable types. In Fortran, each variable name has a unique type associated with it, and this type is either derived implicitly from the first letter of the name, or is explicitly specified in a declaration. In ICL, variable names do not have types — only values have types. A variable gains a type when it is assigned a value. This type can change when a new value is assigned to it. Thus we can have the following series of assignments making the variable X an integer, real, logical, and string in sequence:

    ICL> X = 123  
    ICL> X = 123.456  
    ICL> X = TRUE  
    ICL> X = ’String’

This approach to variable types means that we do not have to declare the variable names we use, which helps to keep programs simple1.


ICL provides a variety of standard functions. They are written as in Fortran, and all the standard Fortran 77 generic functions which are relevant to the ICL data types are provided with the same names. Thus SIN, COS, TAN, ASIN, ACOS, ATAN, ATAN2, LOG, LOG10, EXP, SQRT and ABS are all valid functions. A complete list of functions is given in Chapter 19.


The operators which are used to build up expressions are listed in the following table in order of priority:

    1 (highest)              **  
    2                        *   /  
    3                        +   -  
    4                        =   >   <   >=  <=  <>  :  
    5 (lowest)               NOT   AND   OR   &

The order of evaluation of expressions is determined by the priority of the operators. The rules are the same as those in Fortran2, with arithmetic operators having the highest priority and logical operators the lowest. This means that a condition such as 0 < X + Y 1 can be expressed in ICL as follows:

    X+Y > 0  AND  X+Y <= 1

without requiring any parentheses. However, in general it is good practice to use parentheses to clarify any situation in which the order of evaluation is unclear.

The ‘&’ operator performs string concatenation. If one of its operands is a numeric value, it will be converted to a string. The ‘:’ operator is used for formatting numbers into character strings as described in Section 6.4

In evaluating expressions, ICL will freely apply type conversion to its operands in order to make sense of them. This means not only that integers will be converted to reals when required, but also that strings will be converted to numbers when possible. A string can be converted to a number if the value of the string is itself a valid ICL expression; for example, the string ’1.2345’ has a numeric value. The string ’X+1’ has a numeric value if X is currently a numeric variable (or if X is a string which has a numeric value).

1The disadvantage is that ICL cannot usually spot cases where we accidentally mistype a variable name, as can languages which enforce declaration of variables (such as Fortran with the IMPLICIT NONE directive). This is not thought to be a serious problem for the relatively simple programs for which ICL is intended.

2But different from those in Pascal.