;************************************ ;* * ;*(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. * ;* * ;************************************ ; ; CARD FUNC EntryC() ; ; Universal card-entry routine, ; requires PROC EntryS(), the ; universal string entry routine. ; Includes range check, execute ; on first digit flag, a null- ; entry ok flag, and uses the ; the same XIT flag as ENTRYS. ; ; This routine takes input from ; K: in string form (through ; EntryS) and checks for legal ; value (<=65535) and other useful ; features before converting to ; an actual CARD 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-65535 of course); ; the XEQ, XIT and nullok flags ; are 1 or yes and 0 for no. ; ;************************************ ; INCLUDE "ENTRYS.ACT" ; ;************************************ CARD FUNC EntryC(BYTE col,row CARD minval,maxval BYTE nullok, xeq,xit BYTE POINTER err_ptr) BYTE ARRAY limit(0)="65535", field(0)="....." BYTE fldlen=field BYTE accept,min,max,typec CARD value INT chk min=1 IF minval>10 THEN min==+1 FI IF minval>100 THEN min==+1 FI IF minval>1000 THEN min==+1 FI IF minval>10000 THEN min==+1 FI IF nullok THEN min=0 FI IF maxval=0 THEN maxval=65535 max=5 ELSE max=1 IF maxval>10 THEN max==+1 FI IF maxval>100 THEN max==+1 FI IF maxval>1000 THEN max==+1 FI IF maxval>10000 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=5 THEN chk=SCOMPARE(field,limit) FI IF chk>0 THEN chk=0 MSG(7) ELSE value=VALC(field) IF valuemaxval THEN MSG(7) ELSE accept=1 FI FI UNTIL accept OD RETURN(value) ;************************************ ; ; Example of use of EntryC() PROC Test3() BYTE x,y,nullflg CARD min,max,value BYTE errcde BYTE POINTER err_ptr errcde=0 err_ptr=@errcde min=1000 max=2000 nullflg=0 x=17 y=7 PUT(125) POSITION(5,5) PUTE() PRINTE("Enter a number between ") PRINTC(min) PRINT(" and ") PRINTC(max) PRINT(": ") value=EntryC(x,y,min,max,nullflg, 0,0,err_ptr) POSITION(5,10) PUTE() PRINTCE(value) PRINTE("Done...") RETURN