C+ C NAME: C AskLimit C PURPOSE: C Extract max and min value from query string C CATEGORY: C I/O: user input C CALLING SEQUENCE: logical function AskLimit(cQuery,L,rMin,rMax,rStop) C INPUTS: C cQuery character*(*) string to be used as prompt C OUTPUTS: C AskLimit logical .TRUE. if rMin and rMax are set C L integer length of query string (see PROCEDURE) C rMin double precision minimum permitted value C rMax double precision maximum permitted value C rStop double precision STOP value (see PROCEDURE) C INCLUDE: include 'str2str_inc.h' C CALLS: C itrim, Say, Flt2Str, Str2Str, Str2StrSet, Str2Flt, LocFirstLen C RESTRICTIONS: C > If AskLimit is returned .FALSE., the rMin and rMax values C should not be used (they are returned as -999.0d0) C > Both `rmin' and `rmax' must be present C PROCEDURE: C > used by some of the Ask* procedure to limit the range of permitted C input values. C > The cQuery can contain information about the range of permitted values C in the form: C cQuery = "string$rmin$rmax$rstop" C where C `string' is the query string; C `rmin' and `rmax' (returned in rMin and rMax) define the range C of permissible input values; C `rstop' is the STOP value; C > `rstop' is used to exit the query loop, even if it is outside the range C [rmin,rmax] C > The default value for `rstop' is -999.0d0. C > the length of `string' is returned as L C MODIFICATION HISTORY: C SEP-1994, Paul Hick (UCSD/CASS) C OCT-2002, Paul Hick (UCSD/CASS) C Changed output from single to double precision. C OCT-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Bugfix. For AskLimit=.FALSE., rMin and rMax were not set C to anything. Now they are set to -999.0d0 so the calling routine C is not confronted with a potentially uninitialized variable. C- character cQuery*(*) integer L double precision rMin double precision rMax double precision rStop parameter (LINE = 58) character cH*(LINE) /' '/ character cVal*20 integer Dbl2Str integer Str2Str integer Str2StrSet double precision rVec(3) double precision rStopDef /-999.0d0/ AskLimit = .FALSE. L = itrim(cQuery) ! # chars in cQuery rStop = rStopDef K = LocFirstLen('$',cQuery(:L)) if (K .ne. L+1) then ! $ found L = K-1 ! Discard all chars after $ N = 3 call Str2Dbl(cQuery(K+1:),N,rVec) AskLimit = N .ge. 2 if (N .eq. 3) rStop = rVec(3) end if if (AskLimit) then rMin = rVec(1) rMax = rVec(2) kStr = Str2StrSet(STR__NOTRIM) K = 0 K = K+Dbl2Str(rMin,3,cVal(K+1:)) K = K+Str2Str(',' ,cVal(K+1:)) K = K+Dbl2Str(rMax,3,cVal(K+1:)) kStr = Str2StrSet(kStr) call Say(' ',' ',' ',cH(:max(1,(LINE-30-K)/2))//'Please, select from range ['//cVal(:K)//']') else ! No minimum and maximum determined rMin = rStopDef ! Make sure to initialize with something rMax = rStopDef ! to avoid passing uninitialized stuff to caller end if return end