next up previous
Next: Extended Routines
Up: Abort and Null
Previous: Abort

Null  

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.

          CALL ERR_MARK
          CALL PAR_GET0R( 'WEIGHT', WEIGHT, STATUS )
          IF ( STATUS .EQ. PAR__NULL ) THEN
             WEIGHT = 1.0
             CALL ERR_ANNUL( STATUS )
          END IF
          CALL ERR_RLSE

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.

      100 CONTINUE
          CALL ERR_MARK
          CALL PAR_GET0I( 'NBINS', NBIN, STATUS )
          IF ( STATUS .EQ. PAR__NULL ) THEN
             CALL ERR_ANNUL( STATUS )
             CALL ERR_RLSE
             GOTO 200
          END IF
          CALL ERR_RLSE

              < Perform calculations >

          GOTO 100
          
    *   Come here at the end of the calculations.
      200 CONTINUE



next up previous
Next: Extended Routines
Up: Abort and Null
Previous: Abort

PAR Interface to the ADAM Parameter System
Starlink User Note 114
Malcolm J. Currie
Alan J. Chipperfield
1999 September 24
E-mail:ussc@star.rl.ac.uk