C+ C NAME: C AskR4 C PURPOSE: C Prompt user for real*4 value C CATEGORY: C I/O: user input C CALLING SEQUENCE: subroutine AskR4(cQuery,Valu) C INPUTS: C cQuery character*(*) string to be used as prompt C Valu real*4 default value C OUTPUTS: C Valu real*4 selected value C CALLS: C itrim, Flt2Str, bStr2Flt, AskLimit C INCLUDE: include 'dirspec.h' C RESTRICTIONS: C There is no check for integer overflow C PROCEDURE: C > User is prompted for a new value. The current (input) value is C presented as default. The default is selected by hitting return. C If invalid characters are entered, user will be prompted again. C > A special value for breaking the prompt loop and the range of C permitted input values can be coded into the cQuery string using C appropriate delimiters (see function AskLimit) C MODIFICATION HISTORY: C ???-1991, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- character cQuery*(*) real Valu parameter (LINE = 58) ! Line width character cH*(LINE) /' '/ character cStr*18 character cNew*18 logical bAsk logical Limit logical AskLimit logical bStr2Flt integer Flt2Str double precision dMin double precision dMax double precision dStop Limit = AskLimit(cQuery,L,dMin,dMax,dStop) rMin = sngl(dMin) rMax = sngl(dMax) rStop = sngl(dStop) I2 = max(2,LINE-L) ! If cQuery fits line with one blank ... I1 = I2/2 ! .. on each side, center cQuery on line if (Limit) Valu = max(rMin,min(rMax,Valu)) DefVal = Valu N = Flt2Str(DefVal,8,cStr) bAsk = .TRUE. do while (bAsk) if (cOpSys .eq. OS__VMS) then write (*,'(80(1H ))') ! Clear line write (*,'(1H+,3A,2H< ,A,2H >,$)') cH(:I1),cQuery(:L),cH(:I2-I1),cStr(:N) else write (*,'(1H ,3A,2H< ,A,2H >,$)') cH(:I1),cQuery(:L),cH(:I2-I1),cStr(:N) end if read (*,'(A)') cNew if (itrim(cNew) .eq. 0) then bAsk = .FALSE. Valu = DefVal else if (bStr2Flt(cNew,1,Valu)) then bAsk = Limit .and. Valu .ne. rStop .and. (Valu .lt. rMin .or. Valu .gt. rMax) if (bAsk) then DefVal = max(rMin,min(rMax,Valu)) N = Flt2Str(DefVal,8,cStr) end if end if end do return end