How to Program an Unlimited Input Routine

Ever found that you are doing some routine that requires the user to enter some kind of string of characters and the input command doesn’t seem to fulfil your requirements. Then why not program your own input routine. This is one of mine I have used in various routines such as my own STOS Adventure Creator. It works better because it allows you to move anyway in the text and change it. The STOS input command only allows an limited number of characters but this routine is unlimited.

10 key off : curs off : flash off : hide on : mode 1

15 windopen 1,0,0,80,25,1,4 : curs off

20 get palette (4) : wait vbl

25 dim PAGE$(1000)

30 fastcopy start(4),back : fastcopy back,logic

rem EDIT MODE

612 XW=8 : YW=1 : paper 1 : pen 0

613 locate XW,YW

614 while K$=””

615 K$=inkey$

616 wend

617 rem ~~~ CHECK CURSOR UP KEY

618 if asc(K$)=0 and scancode=72 and YW>1 then dec YW : locate XW,YW

619 rem ~~~ CHECK CURSOR DOWN KEY

620 if asc(K$)=0 and scancode=80 and YW<>21 then inc YW : locate XW,YW

621 rem ~~~ CHECK CURSOR LEFT KEY

622 if asc(K$)=0 and scancode=75 and XW>8 then dec XW : locate XW,YW

623 rem ~~~ CHECK CURSOR RIGHT KEY

624 if asc(K$)=0 and scancode=77 and XW<37 then inc XW : locate XW,YW

625 rem ~~~ CHECK RETURN KEY

626 if K$=chr$(13) then curs off : goto 636

627 rem ~~~ CHECK BACKSPACE KEY

628 if K$=chr$(8) and XW>8 then dec XW : locate XW,YW : print ” “; : locate XW,YW

629 if K$=chr$(8) and XW=8 and YW>1 then dec YW : XW=35 : locate XW,YW : print ” “; : locate XW,YW

632 rem ~~~ CHECK FOR KEYBOARD INPUT

633 if XW=35 and YW=21 then stop

634 if asc(K$)>31 and XW<37 and YW<21 then print K$; : inc XW

635 if asc(K$)>31 and XW=36 and YW<21 then XW=8 : inc YW

636 K$=”” : goto 613

Updated: March 26, 2023 — 9:12 pm
Deanoworld © 2021 Frontier Theme