next up previous
Next: Abort and Null
Up: Basic Routines
Previous: Dynamic Defaults

Inquiring the State of a Parameter  

PAR provides a routine for inquiring the state of a parameter. One practical use for this is to determine whether a parameter is specified on the command line or not, and hence to affect the behaviour of the application. For example, you have an application that loops for efficient and easy interactive use, but in a procedure or batch mode you want the application to process just one set of data.

          INCLUDE 'PAR_PAR'        ! PAR constants
          INTEGER STATE

              :       :       :

          CALL PAR_STATE( 'INIT', STATE, STATUS )

          LOOP = .TRUE.
          DO WHILE ( LOOP .AND STATUS .EQ. SAI__OK )
             CALL PAR_GET0R( 'INIT', START, STATUS )

                 < perform calculation >

             LOOP = STATE .NE. PAR__ACTIVE
             IF ( LOOP ) CALL PAR_CANCL( 'INIT', STATUS )
          END DO

INIT is a parameter required for each calculation. It is obtained within a code loop. If INIT is specified on the command-line, INIT is in the active state before the call to PAR_GET0R. So a logical expression involving the state decides whether there is but one cycle around the loop or many. The include file PAR_PAR contains the definitions of each of the states returned by PAR_STATE. The next section describes how we might end the loop in the interactive case.



next up previous
Next: Abort and Null
Up: Basic Routines
Previous: Dynamic Defaults

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