675 MAP (INBUF) INPUT.LINE$ = 132% ! Buffer for keyboard input. & 16500 !-------------------------------------------------------------------- & ! & ! FN.RESP$ & ! Get an Input Value From the User & ! & !-------------------------------------------------------------------- & ! & ! & ! input: & ! & ! CH.KB% Keyboard channel & ! DEFAULT$ Default answer & ! F.END% Was CNTRL Z entered? & ! FALSE% Logical false value & ! TRUE% Logical true value & ! CNTRL.Z% Error code for CNTL Z & ! PROMPT$ Text of prompt for user input & ! REQUIRED% Is a response required? & ! & ! output: & ! & ! F.END% Was CNTRL Z entered? & ! FN.RESP$ Output of function & ! & ! internal: & ! & ! R$ Edited response & ! INPUT.LINE$ Mapped buffer associated with #CH.KB% & ! WORK$ Work variable & ! & !-------------------------------------------------------------------- & ! & ! NOTE: The following map must appear in the calling program. & ! & ! 675 MAP (INBUF) INPUT.LINE$ = 132% (Buffer for keyboard & ! input) & ! & !------------------------------------------------------------------- & 16520 DEF* FN.RESP$ (PROMPT$, EDIT%, REQUIRED%) & \ ON ERROR GO TO 16550 & ! Set local error trap. 16525 FN.RESP$ = "" & \ F.END% = FALSE% & \ PRINT #CH.KB%, PROMPT$;" "; & \ GET #CH.KB% & \ R$ = EDIT$ (INPUT.LINE$,(4%+8%+128%)) & \ CAP.R$ = EDIT$ (R$, 32%) & \ IF CAP.R$ = "END" & THEN F.END% = TRUE% & \ GO TO 16590 & ELSE IF EDIT% THEN R$ = CAP.R$ & \ R$ = "Y" IF R$ = "YES" & OR R$ = "YE" & \ R$ = "N" IF R$ = "NO" & ! Print the prompt. Get a line of input. Clean it up. Check to see & ! if "END" was typed. & 16530 R$ = DEFAULT$ IF R$ = "" & \ PRINT #CH.KB%, IF R$ = "" AND DEFAULT$ = "" AND REQUIRED% & \ GO TO 16525 IF R$ = "" AND DEFAULT$ = "" AND REQUIRED% & \ WORK$ = EDIT$(EDIT$(INPUT.LINE$,128%),(4%+16%)) & \ PRINT #CH.KB%, IF WORK$ = " " AND LEN(WORK$) = 1% AND REQUIRED% & \ GO TO 16525 IF WORK$ = " " AND LEN(WORK$) = 1% AND REQUIRED% & \ R$ = "" IF WORK$ = " " AND LEN(WORK$) = 1% & \ FN.RESP$ = R$ & \ GO TO 16590 & ! Use default if user just pressed RETURN. & ! Skip error trap. If this is not a required field and the user & ! entered one or more spaces, then return nothing, indicating no & ! response (but not the defualt). 16550 RESUME 16551 IF ERR = CNTRL.Z% OR ERR = CNTRL.C% ERR.CODE% = FATAL.ERROR% GO TO 16590 ! Set up to handle known errors. If any other error, & ! then set ERR.CODE% and trap unexpected fatal error at 19000. & 16551 IF ERR = CNTRL.Z% & THEN F.END% = TRUE% & \ GO TO 16590 & ELSE IF ERR = CNTRL.C% & THEN CLOSE #I% FOR I% = 1% TO 12% & \ WORK$ = SYS (CHR$(9%)) & ! Handle CNTRL Z by setting F.END%. Handle CNTRL C by closing all & ! channels and issuing SYS call to exit prgram. 16590 PRINT #CH.KB% & \ ON ERROR GO TO 19000 & \ FNEND & ! Skip a line. & ! Reset the error trap. &