next up previous
Next: Cancelling Dynamic Values
Up: Basic Routines
Previous: Setting the Dynamic Default

Setting Lower and Upper Limits  

It is a common requirement to restrict a parameter's value to a specific range, or to be above some lower limit or less than some upper limit. For example, the order of a polynomial would have to be positive, but less than some maximum value that the polynomial-fitting software can handle. Whilst this can be done using the range field in the interface file, PAR offers dynamic control through two routines - PAR_MAXx to set the maximum value, and PAR_MINx to set the minimum value for the parameter. Note that there are no logical-type versions of these routines.

Here is an example of setting the minimum value.

    *  The number of histogram bins must be positive.
          CALL PAR_MINI( 'NBINS', 1, STATUS )
          CALL PAR_GET0I( 'NBINS', NBINS, STATUS )

We can set an upper limit too.

    *  The number of histogram bins must be in the range 10 to 1000
    *  inclusive.
          CALL PAR_MINI( 'NBINS', 10, STATUS )
          CALL PAR_MAXI( 'NBINS', 1000, STATUS )
          CALL PAR_GET0I( 'NBINS', NBINS, STATUS )

If the user gives a value outside the legitimate range, an error report appears, and the user is prompted for an acceptable value. In the case of character parameters, the parameter's value follows the minimum value and precedes the maximum value in the ASCII collating list. [*]

If the minimum value is greater than the maximum at the time you get a parameter value, this instructs PAR not to permit values between the minimum and maximum. So the maximum is always the value immediately below the range to be excluded, and the minimum is the value immediately above. In case that is not clear here is an illustration.

    *  Choose an integer excluding -1, 0, 1, and 2.
          CALL PAR_MINI( 'IVALUE', 3, STATUS )
          CALL PAR_MAXI( 'IVALUE', -2, STATUS )
          CALL PAR_GET0I( 'IVALUE', NUMBER, STATUS )



next up previous
Next: Cancelling Dynamic Values
Up: Basic Routines
Previous: Setting the Dynamic Default

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