.TITLE YESNO .IDENT /V1.00/ .ENABL LC ;+ ; YESNO -- This subroutine is used to accept a logical response ; of yes (Y), or no (N) from the terminal and return is to a ; fortran program. Calling sequence; ; ; CALL YESNO (FLAG) ; ; This routine uses INCHAR, the AST driven input routine. ; ; A fortran .TRUE. = -1 ; .FALSE.= 0 ; ; Author : Dave Carroll 17-DEC-82 ; ;- .MCALL QIOW$,DIR$,WTSE$S .NLIST BEX .PSECT DATA,RW,D .EVEN PARS: .WORD 1 .WORD CHAR CHAR: .BYTE 0 .ASCII <15> .EVEN .PSECT RODATA,RO,D BAD: .ASCII /Incorrect answer -- please answer YES or NO ?/ BLEN =.-BAD .EVEN QECHO: QIOW$ IO.WVB,1,1,,,, BECHO: QIOW$ IO.WVB,1,1,,,, .PSECT ROCODE,RO,I YESNO:: MOV R5,-(SP) ; save fortran calling sequence CALL $YESNO ; do the macro version MOV (SP)+,R5 ; restore R5 MOVB R1,@2(R5) ; give the answer RETURN $YESNO::MOV #-1,R1 ; set the value true for starts MOV #PARS,R5 ; set up the calling sequence 1$: CALL INCHR ; attempt to get a character TSTB CHAR ; did we get anything ? BNE 2$ ; yup process it WTSE$S #15 ; wait for a character BR 1$ ; try again ... ; ; Got a character process it ; 2$: DIR$ #QECHO ; echo the response MOVB CHAR,R0 ; get the character BICB #40,R0 ; make the rascal upper case ... CMP #'Y,R0 ; is it yes ... BEQ 10$ ; if so restore, and return CMP #'N,R0 ; is it no ... BEQ 9$ ; set the code and do it CMP #15,R0 ; was it a BEQ 9$ ; yup default to no ; ; wrong answer ... print error and try again for it ; DIR$ #BECHO ; wrong answer BR 1$ ; try it again sam ... 9$: ; ; The answer was no, set the value correctly ; CLR R1 ; set the answer to be no ... 10$: RETURN .END