;************************************ ;* * ;*(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 BYTE FUNC EntryB() ; ; Universal byte-entry routine, ; requires PROC EntryS, the ; universal string entry routine. ; This routine takes input from ; K: in string form (through ; EntryS) and checks for legal ; value (<=255) and other useful ; features before converting to ; an actual BYTE value. ; ; Includes range check, execute ; on single digit flag, a null- ; entry ok flag, and uses the ; the same xit flag as EntryS. ; Use of EntryS allows the same ; user interface (ESC and ^-Z ; handling, timeouts, etc.) ; ; Parameters are self-explanatory; ; minval and maxval are the range ; limits for acceptable response ; (limted to 0-255 of course); the ; XEQ, XIT and nullok flags are ; 1 or yes and 0 for no. ; ;************************************ ; INCLUDE "ENTRYS.ACT" ; ;************************************ BYTE FUNC EntryB(BYTE col,row,minval, maxval,nullok,xeq,xit BYTE POINTER err_ptr) BYTE ARRAY limit(0)="255", field(0)="..." BYTE fldlen=field BYTE accept,min,max, typec,value INT chk min=0 IF minval>0 THEN min==+1 FI IF minval>10 THEN min==+1 FI IF minval>100 THEN min==+1 FI IF nullok THEN min=0 FI IF maxval=0 THEN maxval=255 max=3 ELSE max=0 IF maxval>0 THEN max==+1 FI IF maxval>10 THEN max==+1 FI IF maxval>100 THEN max==+1 FI FI typec=5 ; pos int accept=0 chk=0 DO ENTRYS(field,min,max,typec,xit, col,row,err_ptr) IF err_ptr^#0 THEN RETURN(0) FI ;(calling routine does error handling) IF fldlen=0 THEN field(1)='0 field(0)=1 FI IF fldlen=3 THEN ; overflow chk=SCOMPARE(field,limit) FI IF chk>0 THEN chk=0 MSG(7) ELSE value=VALB(field) IF valuemaxval THEN MSG(7) ELSE accept=1 FI FI UNTIL accept OD RETURN(value) ;************************************ ; ; Example of use of EntryB() PROC Test2() BYTE x,y,min,max,nullflg,value BYTE errcde BYTE POINTER err_ptr errcde=0 err_ptr=@errcde min=100 max=200 nullflg=0 x=15 y=7 PUT(125) POSITION(5,5) PUTE() PRINTE("Enter a number between ") PRINTB(min) PRINT(" and ") PRINTB(max) PRINT(": ") value=EntryB(X,Y,min,max,nullflg, 0,0,err_ptr) POSITION(5,10) PUTE() PRINTBE(value) PRINTE("Done...") RETURN