C+ C NAME: C AskYN C PURPOSE: C Choose YES or NO C CATEGORY: C I/O: user input C CALLING SEQUENCE: subroutine AskYN(cPrmptIn,bYN) C INPUTS: C cPrmpt character*(*) prompt string C OUTPUTS: C bYN logical .FALSE. for NO; .TRUE. for YES C CALLS: C AskChar, itrim C SIDE EFFECTS: C The input is NOT case-sensitive C PROCEDURE: C MODIFICATION HISTORY: C SEP-1994, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C- character cPrmptIn*(*) logical bYN character cPrmpt*80 character cYESNO*6 /'YES,NO'/ character cYN*3 character cWhat*3 cPrmpt = cPrmptIn ! MS-Fortran L = index(cPrmpt,'$') if (L .ne. 0) then L = L+1 ! After '$' bYN = cPrmpt(L:L) .eq. 'y' .or. cPrmpt(L:L) .eq. 'Y' L = L-2 ! Preceding '$' else L = itrim(cPrmpt) end if cYN = 'NO' if (bYN) cYN = 'YES' iP = 0 do while (iP .eq. 0) cWhat = cYN call AskChar(cPrmpt(:L)//' (YES/NO)$u',cWhat) iP = index(','//cYESNO,','//cWhat(:itrim(cWhat))) if (iP .eq. 0) write (*,'(17X,A)') 'Please, answer YES or NO' end do ! iP is position of selected item bYN = cWhat(:1) .ne. 'N' return end