[comp.sys.apple] Input anything routine

rich@pro-exchange.cts.COM (Rich Sims) (08/03/88)

A couple of recent messages have dealt with an "input anything" subroutine.
While it is true that the best way to handle it is with an M/L routine, here's
one that will usually do the job.  It's fairly ancient, but it works.

The drawbacks are (as previously noted) that it's slow (but not *too* bad)
and it does create string garbage (but under ProDOS that shouldn't be a
factor).  The advantage is that it *does* allow editing of the line.
 
This routine will accept any character except the following, and return it in
the input string (which is "A$" in the example shown).
 
        These |  ^H ($08) backspace
        seven |  ^M ($0D) return (terminates the input)
   characters |  ^U ($15) right arrow
          can |  ^X ($18) cancel (cancels input line to this point)
          not |  ^[ ($1B) escape
           be |  ^^ ($1E)
      entered |     ($7F) delete

{TheRoutine}
 
100 PRINT "Your prompt string: ";: CALL -657
110 A$ = "": FOR X = 512 TO 767: IF PEEK (X) <> 141 THEN
       A$ = A$ + CHR$(PEEK (X) -128): NEXT
 
I don't know where this routine originated, but it appeared on one of the old
Beagle Brothers "peek, pokes, and pointers" wall charts.
 
Hope this is of some use to some of you.
 
UUCP: [ sdcsvax nosc ] !crash!pro-exchange!rich || pro-exchange: 305/431-3203
ARPA: crash!pro-exchange!rich@nosc.mil          ||  300/1200/2400/9600 (HST)
INET: rich@pro-exchange.cts.com                 ||     login = 'register'