Should you wish to combine the constraints of a numeric value within a range, and a list of options, there are PAR routines to do it for you. Here is an illustration to show how this might be profitably used. The application from which the following extract is taken wants to replace certain array values with a constant; this can either be a numeric value or set to the bad-pixel value.
CHARACTER * ( VAL__SZR ) CNEWLO, THLDEF : : : * Get the replacement value. THLDEF = '0.0' CALL PAR_MIX0R( 'NEWLO', THLDEF, VAL__MINR, VAL__MAXR, : 'Bad', .FALSE., CNEWLO, STATUS ) IF ( STATUS .EQ. SAI__OK ) THEN * It may be the bad-pixel value. IF ( CNEWLO .EQ. 'BAD' ) THEN NEWLO = VAL__BADR ELSE * Convert the output numeric string to its numeric value. CALL CHR_CTOR( CNEWLO, NEWLO, STATUS ) END IF END IF
This obtains from parameter NEWLO a value which is either 'BAD' or a real value. The value is returned in variable CNEWLO. VAL__MINR and VAL__MAXR are the minimum and maximum values, and VAL__BADR is the bad value, for the real data type, and VAL__SZR is the maximum number of characters needed to store a real value; all symbolic constants are defined in the PRM_PAR include file ( SUN/39). The dynamic default is '0.0'. Remember that the dynamic default and returned value are strings. Therefore, you must first test the returned value for being any of the items on the menu, before converting it to a number. Since the returned value may be undefined following an error, it is prudent to check the status before using the value.
Should the user give an unacceptable value, PAR_MIX0x informs the user of the error and lists the available options, and then invites the user to supply another value.
Here is a more subtle example. This only has numbers in the menu, but it is advantageous when only certain numeric values are acceptable.
* Get the plate number. CALL PAR_MIX0I( 'PLATE', ' ', 101, 1500, '5,11,23,47,49', : .FALSE., CPLATE, STATUS ) IF ( STATUS .EQ. SAI__OK ) : CALL CHR_CTOI( CPLATE, PLATNO, STATUS )
Here PAR_MIX0I obtains an `integer' that is either 5, 11, 23, 47, 49, or in the range 101-1500, and returns it in the character variable CPLATE. CHR_CTOI converts the string into a true integer value, PLATNO. Since the second argument of PAR_MIX0I is a blank string, there is no dynamic default. To produce a suggested default, the second argument would have to be one of the menu options, or satisfy the range constraint (when converted to an integer). If we had swapped the range limits, PAR_MIX0I would allow all values not in the range 102-1499.
PAR Interface to the ADAM Parameter System