8-Bit Software Online Conversion
Presenting Programs Example - Listing
10REM >FillIn
20REM by Steven Flintham
30REM
40REM A program to demonstrate the "a
utomatic fill in" method of input
50REM
60REM Saturday 28th August 1993
70REM Thursday 2nd September 1993
80:
90MODE 7
100PROCdisable
110PROCinit
120PROCtitle
130PROCset`up`choices
140PROCshow`choices
150PRINT'"Your choice?";CHR$131;
160choice$=FNfill`in(choices%,FALSE)
170PRINT'"You chose ";choice$
180PROCenable
190END
200:
210DEF PROCdisable
220*FX229,1
230*FX4,2
240ENDPROC
250:
260DEF PROCenable
270*FX229
280*FX4
290ENDPROC
300:
310DEF PROCinit
320ON ERROR MODE 7:REPORT:PRINT " at l
ine ";ERL:PROCenable:END
330DIM fill`in$(10)
340ENDPROC
350:
360DEF PROCtitle
370PRINTTAB(5,0);CHR$141;CHR$132;CHR$1
57;CHR$131;"Fill-in demonstration ";CHR
$156
380PRINTTAB(5,1);CHR$141;CHR$132;CHR$1
57;CHR$131;"Fill-in demonstration ";CHR
$156
390PRINTTAB(6,2);CHR$131;"(C) Steven F
lintham 1993"
400ENDPROC
410:
420DEF PROCset`up`choices
430LOCAL read%
440RESTORE 510
450READ choices%
460FOR read%=1 TO choices%
470READ fill`in$(read%)
480NEXT
490ENDPROC
500:
510DATA 9
520DATA Number,Nuts,Natural,Distinct,A
djacent,Address,Num,Print,Printout
530:
540DEF PROCshow`choices
550LOCAL show%,pos%
560PRINTTAB(0,4);"The options are:";:p
os%=POS
570FOR show%=1 TO choices%
580PRINTTAB(pos%,3+show%);CHR$131;fill
`in$(show%)
590NEXT
600ENDPROC
610:
620DEF FNfill`in(choices%,allow`null%)
630LOCAL
640pos%=POS:vpos%=VPOS
650user$=""
660longest%=-1
670FOR check%=1 TO choices%
680IF LEN(fill`in$(check%))>longest% T
HEN longest%=LEN(fill`in$(check%))
690NEXT
700REPEAT
710REPEAT
720*FX21
730key%=GET
740IF key%>=ASC("a") AND key%<=ASC("z"
) THEN key%=key%-32
750UNTIL key%>=ASC("A") AND key%<=ASC(
"Z") OR key%=13 OR key%=127
760IF key%<>13 AND key%<>127 THEN user
$=user$+CHR$(key%)
770IF key%=127 AND LEN(user$)>0 THEN u
ser$=LEFT$(user$,LEN(user$)-1)
780match%=-1
790FOR check%=1 TO choices%
800IF FNto`upper(fill`in$(check%))=use
r$ THEN match%=check%
810IF LEFT$(FNto`upper(fill`in$(check%
)),LEN(user$))=user$ AND match%=-1 AND u
ser$<>"" THEN match%=check%
820NEXT
830IF key%<>13 AND key%<>127 AND match
%=-1 THEN user$=LEFT$(user$,LEN(user$)-1
)
840IF match%<>-1 THEN PRINTTAB(pos%,vp
os%);fill`in$(match%);SPC(longest%-LEN(f
ill`in$(match%)));TAB(pos%+LEN(user$),vp
os%); ELSE PRINTTAB(pos%,vpos%);SPC(long
est%);TAB(pos%,vpos%);
850UNTIL key%=13 AND (allow`null% OR m
atch%<>-1)
860IF match%=-1 THEN ="" ELSE =fill`in
$(match%)
870:
880DEF FNto`upper(old$)
890LOCAL new$,pos%,char%
900IF old$="" THEN =""
910new$=""
920FOR pos%=1 TO LEN(old$)
930char%=ASC(MID$(old$,pos%,1))
940IF char%>=ASC("a") AND char%<=ASC("
z") THEN char%=char%-32
950new$=new$+CHR$(char%)
960NEXT
970=new$