It must be admitted that the previous example has limited value. The facility to specify VALUE
at run-time would be an improvement. A simple READ statement might seem like the
answer, but as mentioned before, this approach is likely to fall foul of the way in which
the ADAM environment deals with I/O. In any case, using the parameter system gives
enormous advantages – as will become clear. (Already one ADAM parameter has been
used in the example programs – the ’INPUT’ used to get the name of the input NDF for
NDF_ASSOC.)
The program on the previous page could be modified by replacing the statement assigning 7.0 to VALUE with the call below which gets an ADAM parameter, in this case, named ’CONST’.
This change has been made in ADAM_EXAMPLES:ADDCONST.FOR. The ‘PAR_GET’ part is self explanatory, and the ‘0’ indicates that the parameter to be retrieved is a scalar (rather than a vector, or an -D object). The final ‘R’ in the subroutine name indicates that the routine retrieves a variable of type REAL. Similarly PAR_GET0I retrieves an integer, PAR_GET0C, a character string etc. A list of the PAR routines with their functions and calling sequences is given in Appendix D.
The ADAM parameter ’CONST’ must now be declared in the interface file as shown:
When the PAR_GET0R routine is called, it looks to the interface file for instructions on retrieving the parameter in question. In this case, the only information found there is that the prompt ’Value to be added?’ should be issued. If a suitable number is then entered by the user, it is assigned to VALUE and STATUS remains ‘OK’. Any unsuitable response (e.g. a logical value) and the parameter system will issue an error message, and doggedly repeat the prompt five times or until a satisfactory value is entered.
The prompt
is an example of a fieldname. Other fieldnames which are commonly defined in interface
files are discussed briefly below, and a full discussion of the subject of interface files is contained in
SUN/115.
$ RUN ADDCONST
, you can set up a symbol:
where mydir is the logical name of the directory which contains ADDCONST.EXE. Typing
ADDCONST
will now cause execution of the program. It is now possible to enter the parameters
the program needs on the command line. Possible that is, if the program knows the
order in which to expect them. Including the lines, “position 1
” and “position 2
”
within the parameter declarations of ’INPUT’ and ’CONST’ respectively provides this
information. After modifying the interface file in this way, the example command below will
work.
It is not recommended that keywords be explicitly declared in interface files.
This suggested value (17.4) is used if the user presses
CR
in response to the prompt. The fieldname ppath
is used to specify where the parameter system
gets this suggested value. For example, if ppath is declared as current
, the value supplied for
the parameter during the previous run of the program will be used. It is also possible to select a
fixed default value which is supplied via the default
fieldname. In the example
interface file below, the parameter INPUT
has been given a default value of SPECTRUM
.
However, ppath for INPUT
has been set to ’current,default’
. This means that the
prompt will contain the current value – that is, the last value assigned to the INPUT
parameter – unless no value has been assigned, in which case the value specified by the
default
fieldname will be used. Other possibilities for defining ppath are described in
SUN/115.
default
, range
or in
fieldnames are
declared.
A modified version of ADDCONST.IFL incorporating some of the above fieldnames is shown below.
Some of the values assigned to fieldnames above are surrounded by quotes ’ ’. This is necessary if the values are character constants (such as the prompts), or contain more than one word (such as the ppath) but is optional otherwise. Comments in interface files are preceded by the ‘#’ symbol.