;************************************ ;* * ;*(C)Copyright 1986 by Paul B. Loux * ;* * ;* These routines are in the public * ;* domain, and are not to be sold * ;* for a profit. They may be freely * ;* distributed, provided that this * ;* header remains in place. Use and * ;* enjoy! PBL, CIS 72337,2073. * ;* * ;************************************ ; ; File ENTRYYN.ACT ; ; BYTE FUNC EntryYN() ; ; Returns either one or zero ; (true/false), representing a ; one-character (Y or N) user ; response to yes/no questions ; (uses EntryS(),the universal ; string entry utility, to get ; the keystroke). ; ; The routine supports typical ; EntryS() features, including ; screen coordinates supplied ; by the calling routine; pass ; through of error codes, for ; ESC and Ctrl-Z handling; and ; timeouts. This routine also ; allows a default value for a ; null-response (if desired). ; ; Parameters: ; ; col=screen echo horiz column ; row=screen echo vert column ; ; default= 0 for null="N" ; 1 for null="Y" ; 2 to disallow null ; ; err_ptr= pointer to pass err ; to calling routine. ; ;************************************ ; INCLUDE "ENTRYS.ACT" ; ;************************************ ; ; BYTE FUNC Ask_YN(BYTE col,row,default BYTE POINTER err_ptr) DEFINE max ="1", typec="7", xit ="0" BYTE response,min BYTE ARRAY field="x" IF default=2 THEN min=1 ELSE min=0 FI DO ENTRYS(field,min,max,typec,xit, col,row,err_ptr) IF err_ptr^#0 THEN RETURN(0) FI IF field(0)=0 THEN ; null entry IF default=0 THEN PUT('N) ELSE PUT('Y) FI RETURN(default) FI response=field(1) IF response=89 THEN ; 'Y RETURN(1) ELSEIF response=78 THEN ; 'N RETURN(0) FI OD RETURN(0) ; ; ;************************************ ; ; Example of usage: PROC Test8() BYTE answer BYTE x,y,default BYTE errcde BYTE POINTER err_ptr errcde=0 err_ptr=@errcde x=33 y=5 default=0 PUT(125) POSITION(1,5) PRINT("Do you own a computer (Y/[N]): ") answer=Ask_YN(x,y,default,err_ptr) POSITION(1,7) IF answer THEN x=26 y=7 default=1 PRINT("Is it an Atari ([Y]/N): ") answer=Ask_YN(x,y,default,err_ptr) POSITION(1,9) IF answer THEN x=17 y=9 default=2 PRINT("Is it an 8-bit? (Y/N)") answer=Ask_YN(x,y,default,err_ptr) POSITION(1,11) IF answer THEN PRINT("Congratulations.") ELSE x=9 y=11 default=0 PRINT("520 ST? (Y/[N])") answer=Ask_YN(x,y,default,err_ptr) POSITION(1,13) IF answer THEN PRINT("Congratulations.") ELSE PRINTE("Must be a 1040 ST then.") FI FI ELSE PRINTE("Too bad.") FI ElSE x=32 y=7 default=1 POSITION(1,7) PRINTE("Too bad.") FI RETURN