User`s manual

H-1
H / User Programs
Special Keyboard Input Routine
Here's a general-purpose keyboard input routine (lines 100-175) for use in any
program where the user will need to input a specific number of characters. Lines
1000-1040 contain a demonstrator program, which calls the routine.
When the main program asks for the field length, you can type in either a negative or
positive number. If you type a negative number, the input routine will only let you
enter numeric characters (including a leading + or _ sign-character, one decimal point,
and the digits 0-9). If you type a positive number for the field length, only any
alphanumeric characters may be input.
The routine returns the input string in the variable IN$.
1 ' EXAMPLE OF RADIO SHACK'S INKEY ROUTINE
2 '
5 CLS: CLEAR 500: GOTO 1000
70 '
80 ' *** INKEY ROUTINE - LINES 100 THROUGH 175
90 '
100 IN$="":W$=INKEY$:W=14:WD=0:WS=WD:WL%=WD:IFFL=WDTHENFL=1
105 PRINTSTRING$(BBS(FL),136);STRING$(RBS(FL),24);
110 PRINTCHR$(W);:FORW%=1TO25:W$=INKEY$:IFW$<>""THEN115ELSENEXT:
PRINTCHR$<i5);:FORW%=1TO25:W$=INKEY$:IFW$<>""THEN115ELSENEXT:
GOT0110
115 PRINTCHR$(W);:IFABS(FL)=WL%THEN125
ELSEIFFL>0ANDW$>=" "ANDW$<="Z"THEN170
ELSEIFFL<0ANDW$>"/"ANDW$<":"THEN17O
117 IFW$=","THENPRINTW$;:WL%=WL%+1:GOT0175
120 IFW$="."ANDWD=0THENWD=1:GOTO170
123 IF(W$="-"ORW$="+")ANDWS=0ANDWL%=OTHENWS=1:GOT0170
125 IFW$<>CHR$(B)THEN150ELSEIFWL%=0THEN110ELSEPRINTCHR$(24);:
IFFL>0THEN135ELSEIFPEEK(16418)=44THEN140
130 IFPEEK(16418)=46THENWD=0:GOT0135
ELSEIFPEEK(16418)=43ORPEEK(16418)=45THENWS=0
135 IN$=LEFT$(IN$,LEN(IN$)-1)
140 WL%=WL$-1:POKE16418,136:GOTO110
150 IFW$=CHR$(24)THENPRINTSTRING$<WL%,CHR$(24));:GOTO100
155 IFW$<>CHR$(13)THEN110ELSEPRINTSTRING$(ABS(FL)-WL%,32);
160 PRINTCHR$(15);:W%=25:NEXT:RETURN
170 PRINTW$;:IN$=IN$+W$:WL%=WL%+1
175 IFABS(FL)=1THEN166ELSE110