Tuxtoo - 2020-04-25

As a BASIC beginner I am looking for tutorials and if there are any BASIC beginners out there they may find these YouTube videos useful. The only problem is they are for Commodore BASIC, however the techniques explained are still relevant.

I was looking for an input routine came across a suitable tutorial by Jay Versluis on his YouTube Channel which gives a succinct explanation of coding an input routine.

Below is my attempt at converting Jay’s program to GW-BASIC which limits the input to the characters A-Z and a-z. I know there are more improvements that can be made, e.g. limit the length of the input string or the characters that can be input to name a few.

Anyway here’s my attempt. I am sure there are many more custom input routines out there, but I have been unable to find them (yet). If anyone cares to suggest improvements of have their own input routine and would care to share them and help me learn, please do.

10 CLS
20 ROW=CSRLIN
30 COL=POS(X)
40 LOCATE ROW,COL,1
50 W$=""                                                                        
60 A$=INKEY$:IF A$="" THEN 60                                                   
70 A=ASC(A$)                                                                    
80 IF A=13 THEN 160:REM return                                                  
90 IF A=32 THEN 120:REM space 
100 IF A=8 THEN 180:REM backspace
110 IF A<65 OR A>90 AND A<97 OR A>122 THEN 60
120 PRINT A$;                                                                   
130 COL=COL+1
140 W$=W$+A$                                                                    
150 GOTO 60                                                                     
160 IF W$=""THEN PRINT:PRINT "You printed nothing!":END
165 PRINT: PRINT "You typed: ";:PRINT W$
170 END                                                                         
180 IF LEN(W$)=0 THEN 60: REM process backspace
190 W$=LEFT$(W$,LEN(W$)-1)                                                      
200 COL=COL-1
210 LOCATE ROW,COL,1
220 A$=CHR$(32)                                                                 
230 PRINT A$;
240 LOCATE ROW,COL,1
250 GOTO 60
 

Last edit: Tuxtoo 2020-04-25