next up previous
Next: Combined Constraints
Up: Extended Routines
Previous: Parity Constraint

Menu Constraint  

A common requirement is to select an option from a menu. PAR_CHOIC offers this functionality. You provide a list of options separated by commas. When the user selects a choice not in this menu, an error report appears that lists the available options, and the user is prompted. [*] PAR_CHOIC permits the user of your application to use an unambiguous abbreviation. However, the unshortened value is returned. The value is also in uppercase, though the list of options need not be so.

          CHARACTER * 10 FUNCT, OPTDEF
          CHARACTER * 72 OPLIST

              :       :       :

          OPLIST = 'Exit,Device,Histogram,List,Peep,'/
         :         /'Region,Save,Slice,Statistics,Value'
          OPTDEF = 'Region'
          CALL PAR_CHOIC( 'OPTION', OPTDEF, OPLIST, .FALSE., FUNCT, STATUS )

So in the above example there are ten options available for parameter OPTION. The dynamic default is 'Region'. If you assign the second argument with a value not in the main list, such as a blank string, it instructs PAR_CHOIC not to set a dynamic default. Note that PAR_CHOIC only returns character values.

This is what the user might see for the above example.

    OPTION - Inspection option /'Region'/ > View
    !! The choice View is not in the menu.  The options are
    !     Exit,Device,Histogram,List,Peep,Region,Save,Slice,Statistics,Value.
    !! Invalid selection for parameter OPTION.
    OPTION - Inspection option /'Region'/ > S
    !! The choice S is ambiguous.  The options are
    !     Exit,Device,Histogram,List,Peep,Region,Save,Slice,Statistics,Value.
    !! Invalid selection for parameter OPTION.
    OPTION - Inspection option /'Region'/ > lust
    Selected the nearest match "LIST" for parameter OPTION.

The first value is unacceptable as it is not in the menu. The second is ambiguous because there are several options beginning with an ess. Had the user entered sl say, the abbreviation would have selected a value of 'SLICE'. The final value appears not to be in the list of choices, but PAR_CHOIC allows the user one typing mistake, and so the user actually selects option 'LIST'. In this case, a warning message is output unless the MSG filtering level is set to `quiet'.

There is a similar routine - PAR_CHOIV - to get a vector of character values from a menu.



next up previous
Next: Combined Constraints
Up: Extended Routines
Previous: Parity Constraint

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