1 ' LINE25.BAS by 2 ' Larry Schwartz 100 ' [Clear line 25 for the prompt.] 110 LOCATE 25,1 : PRINT TAB(79); 115 LOCATE ,1 120 ' 125 ' [Display the prompt. The 130 ' semicolon at the end causes the 135 ' cursor to stay immediately 140 ' after the last character of the 145 ' prompt (here a blank).] 150 PRINT "prompting message===>"; 160 ' 170 ' [Initialize the answer 175 ' "build-up"variable to null.] 180 ANSWER$ = "" 190 ' 195 ' [Use the INKEY$ function to 200 ' return one "logical" keyboard 205 ' character. The "character" is 210 ' placed in TEMP$ and may have a 215 ' length of 0, 1, or 2. See the 220 ' end of Appendix G, and the 225 ' INKEY$ writeup in the BASIC 230 ' manual for a detailed 235 ' description.] 240 TEMP$ = INKEY$ 250 ' 260 ' [If the length is 0. no 265 ' character was available 268 ' from the keyboard, so it is 270 ' necessary to go back and try 275 ' again for another character.] 280 IF LEN(TEMP$) = 0 THEN GOTO 240 290 ' 295 ' [If the length is 2, an 300 ' "extended" key was pressed 305 ' (combination of some key and a 310 ' Shift, Alt, or Ctrl. In this 315 ' example, we do not want them so 320 ' we call an error msg routine 325 ' and then restart the whole 328 ' procedure.] 330 IF LEN(TEMP$) = 2 THEN GOSUB 9999 : GOTO 100 340 ' 345 ' [If we get here, the length was 350 ' 1 (normal) so we want to keep 355 ' the character and concatenate 360 ' it to our "working answer" 365 ' variable. We display the 370 ' character using the current 375 ' position of the cursor and again 380 ' leave the cursor where it is. 385 ' Since the character wasn't an 390 ' "enter", there is more to come, 395 ' so we go back for the next 400 ' character. If the character 405 ' was an "enter", CHR$(13), then 410 ' that signals the end of the 415 ' user's input and we don't go 420 ' back. Because the "enter" is 423 ' not displayed, the cursor stays 425 ' in place and the screen doesn't 428 ' scroll.] 430 IF TEMP$<>CHR$(13) THEN ANSWER$=ANSWER$+TEMP$:PRINT TEMP$;:GOTO 240 440 ' 445 ' [In this example, we permit a 450 ' "null" response, so we set 455 ' RESULT to the default value if 460 ' the input was null or to (in 465 ' this example) the numeric value 470 ' of the characters we have built 475 ' up in ANSWER$.] 480 IF ANSWER$ = "" THEN RESULT = DEFAULT ELSE RESULT = VAL(ANSWER$) 490 ' 495 ' [Finally, a range check is 500 ' performed on RESULT. If out of 505 ' range, the error message 510 ' subroutine is called and we 515 ' start all over.] 520 IF RESULT THEN GOSUB 9999 : GOTO 110 530 ' 540 RETURN