next up previous 63
Next: Graphics with ADAM
Up: Writing ADAM tasks
Previous: STATUS and error handling


Returning values to ICL

We have already seen how ICL can be used to supply values for ADAM task parameters. It is also possible for ADAM tasks to return values to ICL. The following modified version of SQUARE does not output its result on the terminal, but returns it to the parameter VALUE using a call to the routine PAR_PUT0R which is analogous to PAR_GET0R.

      SUBROUTINE SQUARE(STATUS)
      INTEGER STATUS
      REAL R,RR
      CALL PAR_GET0R('VALUE',R,STATUS)
      IF (STATUS .EQ. SAI__OK) THEN
         RR = R*R
         CALL PAR_PUT0R('VALUE',RR,STATUS)
      ENDIF
      END

We could run this from ICL as follows (having done a DEFINE SQUARE SQUARE) to define the command:

    ICL> X=5
    ICL> SQUARE (X)
    ICL> =X
    25
    ICL>

In order for the ADAM task to return a value to ICL we must use a variable for the parameter and place it on the command line. The variable name must be placed in parentheses, then the name of a temporary HDS object is substituted by ICL.

A modification of this scheme is needed with character variables to allow the case where the contents of the character variable is itself a device, file or object name. In such cases, the supplied name cannot be replaced by some other name so, to indicate that they may not be replaced, name values in variables must be preceded by @.


next up previous 63
Next: Graphics with ADAM
Up: Writing ADAM tasks
Previous: STATUS and error handling

ICL The Interactive Command Language for ADAM
Starlink Guide 5
J A Bailey
A J Chipperfield

9th June 1998
E-mail:starlink@jiscmail.ac.uk

Copyright © 2013 Science and Technology Facilities Council