There are two special status values that can be returned by the parameter system when getting parameter values. They are PAR__ABORT and PAR__NULL, and are defined in the include file PAR_ERR.
PAR__ABORT is returned if a user enters !!
in response to a prompt. In this event you should ensure
that your application exits immediately. In practice this means that a) the user is not be prompted for
any further parameters, though you do not have to check for an abort status after every PAR_GET call
– the inherited status will look after that – and b) the application exits cleanly, freeing any resources
used. There must be a status check before any of the parameter values are used, in case they have not
been obtained successfully.
For example
performs three parameter get calls, before testing for an abort; if an abort status is found, the routine exits. The status check against PAR__ABORT is unusual, and it is included to illustrate the symbolic constant. In normal circumstances you would test whether STATUS and SAI__OK were not equal, since it checks whether any error has occurred.
PAR__NULL indicates that no value is available, and may be interpreted according to circumstances.
This normally occurs when a user assigns a value of !
to a parameter.
Null can be used in a variety of circumstances. These include to end a loop, to indicate that an optional file is not required, and to force a default value to be used.
Here is an example of handling null as a valid value for a parameter.
When the PAR_GET0R returns with the null status, the variable WEIGHT is set to 1.0. This particular instance has limited value, but the constant could be dynamic, depending on the values of other parameters or data read from files. The call to ERR_ANNUL restores STATUS to SAI__OK, and also removes an error message that would otherwise be reported later (usually when the application completes). Since we do not want to lose any earlier error reports, ERR_MARK and ERR_RLSE bracket this fragment of code to set up and release an error context. See SUN/104 for further details.
Here null ends a loop, say to plot an histogram with different numbers of bins.