Classic Computer Magazine Archive ANTIC VOL. 3, NO. 5 / SEPTEMBER 1984

The Toolbox


A shortcut to program typing


A devilishly clever technique for setting up two-keystroke "function-key" abbreviations that'll enter repeats of lengthy commands into your program.  The BASIC listing requires a disk drive, and runs on all Atari computers of all memory configurations.  Antic Disk Subscribers Run "D:BASICKEY.BAS"

How many times have you typed 'A$(LEN(A$)+1)=', or 'COLOR 1', or 'SAVE "D:', until you thought your fingers were going to fall oft?  Wouldn't it be nice if you could just press one key...?
   If you've done much programming in ATARI BASIC, you've encountered the finger cramping, shift key workout more than once. In fact if you're like me, you have found yourself wishing that ATARI had assigned function keys to save some typing.
   Well they didn't.  So one night just after I had finished my 43rd A$(LEN(A$) + 1 = " "', I decided to do something about it. The following autorun program allows you to use the [CTRL] key and one other key to generate complete BASIC commands.  In this program, the [CTRL] key and any other key can be used to print entire BASIC functions.  If you assign the 'LIST "P:"' command to the [4] key, for example, every time you type [CTRL] [4] the 'LIST "P:"' command will appear on the screen.
   It's easy to assign any BASIC command to any key.  You can assign commands to their keys in lines 20000-29999 in the BASIC program.  When making these assignments, you must follow a few simple rules:

1. Change only the string data between lines 20000 and 29999.
2. The last command string must be '@@@@@'.
3. Every assignment must follow this pattern:
   (KEY is any key, A-Z, 0-9.
   (COMMAND) is the command you want the key to produce.
   [:COMMAND:... :COMMAND] are any additional commands (optional).
   (@) is an end-of-command marker.
4. Use '\' symbols instead of commas in your command strings. The program will read them as commas.
5. The maximum length of any command string is 128 bytes.

EXAMPLE: Let's say we want the '4' key to generate 'PRINT"Answer Yes or NO":INPUT A$', instead of 'LIST "P:"'. The BASIC data statement we need to change is in line 20150.  Change line 20150 from:

20150 DATA 4LIST "P:"@,5LIST "D:@


20150 DATA 4PRINT"Answer Yes or NO":INPUT A$@,5LIST "D: @

The '4' key is changed.

Once you've made the key assignments, you must create the AUTORUN.SYS file.  With a formatted disk (with the DOS.SYS and DUPSYS files) at hand, RUN the program.
  The program will ask you if you want a hard copy of your command set, just in case your memory needs refreshing once in a while.  Type [Y] for "yes," [N] for "no".  After the program has read your command set, it will ask you to place your formatted disk in drive #1.  Do so.  Press [RETURN] to create and store the AUTORUN.SYS file on the disk.  Now, SAVE our KEY FUNCTION program to the disk as a backup, if you haven't already done so.  To run the AUTORUN.SYS file, turn the ATARI off and then on again.  The program will automatically load and patiently wait for you.  Test the program by pressing the [CTRL] key while typing a key to which you have assigned a command.  If it works, your command will appear on the screen.  If a command didn't appear, check the data statements.

1. Don't assign anything to the [1] key, it will disable the [CTRL] [1] screen freeze.
2. Always press the [RESET] key before going to DOS.  To recover the function keys after going to DOS, you must reboot.
3. Never use 'NEW' in a multiple command statement.  Anything after it will be ignored.

A sample data set is included to allow you to experiment.  The [CTRL] [0] command is a short routine that converts a hex digit to decimal.


The BASIC program builder is a fairly straightforward disk output routine with the following "tricks":

1. In line 10000, the first 6 bytes are the binary file load header.
2. In the data statements between 10000 and 19999, values 500 and 501 are flags to tell the program where to put the end address of the assembly program and key data.
3. Line 30040 is the append data you need to make ATARI DOS think the file is an auto execute file.

   The function key program starts by loading below the DOS.SYS program area and then shifting the MEMLO and APPMHI pointers to the end of the key data.  Then the program puts its keyboard handler address into the jump vector at VKEYBD($209) and saves the old jump vector in its own jump location. (A positive side effect of this is that the program only uses the exact amount of memory it needs.) Then the program returns to BASIC.
   When a key is pressed, the interrupt jumps to the function program.  There, its value is checked to see if the [CTRL] key is pressed.  If not, the program continues through the normal keyboard handler.  When the [CTRL] key is pressed, the key character is converted to ASCII and compared with the command table.  If a match is found, the command is sent to the screen and an 'RTI' (ReTurn from Interrupt) is effected.  If no match is found, the registers are restored and processing continues through the normal handler.

Listing: BASICKEY.BAS Download