!pr0
!lm12
!rm75
TRAPPER:  An Applesoft Input Tuner...............Allen Marsalis

How would you like a radio which played every available station at one time?  Well that's how I sometimes feel about using Applesoft's INPUT statement.  I want to be able to "tune in" on the character(s) of the input stream, in much the same way as a radio tunes into a station.  Applesoft's INPUT statement, however, accepts all characters typed into the keyboard and allows up to 255 of them.  This means that I have to do a lot of checking and monitoring of string lengths and characters to avoid input errors.

For example, when answering a Y or N question, what happens when the user inputs "WXYZ"?  Provisions are needed within the program to guard against such errors.  This can be very inconvenient and space-consuming, yet it is essential for good programming.

A better example occurs when you are creating a disk file.  Field lengths and data types are often restricted, such as in a name, address, or social security number.  A SSN, for instance, has a fixed length and must be constructed of numbers only.  Checking a field such as this can be very time consuming and lengthy.  In fact, it seems that a quarter of the contents of my Applesoft programs does nothing but check on field lengths, option boundaries, and other input checks.

So, I set out to create an input routine which would allow Applesoft to "tune" into the characters specified and also monitor the field length.  I've seen several input routines such as this on larger systems, but all had one disadvantage:  Only a fixed number of options were available, such as alpha only, numeric only, and (Y or N) input.  More options available meant more parameters were necessary, making the systems more cumbersome to work with.  After much thought I decided on a totally new approach which would allow almost limitless control of input.  I christened this routine TRAPPER for "Tuning and Regulating APPlesoft Entries by Restriction."

TRAPPER employs a coded restriction string (not unlike Applesoft's IF expression) to tune out the characters I don't want to accept.  TRAPPER is then, in essence, a tiny interactive interpreter that provides a short, convenient method of filtering out any unwanted characters in the input.  Here's how it works.

TRAPPER uses three parameters as follows:

Syntax:  & INPUT (A, B$, C$)
     A:  Input field length (real expression)
    B$:  Coded restriction string (string expression)
         includes:  > < = ' AND OR NOT <sp> <single char>
    C$:  Input string (string variable)
         variable to receive input
!np
As I have said, the restriction string is a simple relational expression as is used by Applesoft's IF statement.  It is constructed of the following special characters and rules:

!lm+10
!pp-4
1)  < > = are its relational operators
2)  AND OR NOT are its logical operators
3)  Blanks are allowed anywhere within the expression, but lengthy expressions increase the delay between keystrokes.
4)  One and only one character is allowed within single quotes.
5)  <cr> and <-- have special functions and cannot be trapped.
6)  Parentheses are not yet implemented.

!lm-10
!pp0

EXAMPLES:

!lm+4
YN$ = " ='Y' OR ='N' "            :REM (Y OR N) ONLY
NOSP$ = " NOT =' ' "              :REM NO SPACES ALLOWED
MENU$ = " NOT <'1' AND NOT >'4' " :REM ALLOWS 1 THRU 4
WAITCR$ = ""                      :REM WAIT FOR A <CR>
!lm-4

After using Trapper awhile, I noticed a significant reduction in the size of my Applesoft programs, with even better error trapping than ever before possible.  And it doesn't print that leading question mark which I never did like (not all input prompts are questions.)

For a 48K Apple, DOS sets HIMEM at $9600.  Trapper resides just below this at $9300 and moves HIMEM down to that point.  
