Classic Computer Magazine Archive COMPUTE! ISSUE 70 / MARCH 1986 / PAGE 107

Softkeys For Atari BASIC

Raymond Citak

This labor-saving utility adds automatic line numbering and 19 preprogrammed "soft" keys to your Atari computer. Even better, the soft key assignments are compatible with COMPUTE!s "Automatic Proofreader. " For any Atari 400/800, XL, or XE computer with at least 48K RAM.

If you write your own BASIC programs or enter the programs listed in COMPUTE!, you'll welcome any utility that cuts down on your typing time. "Softkeys For Atari BASIC" does exactly that—it gives you automatic line numbering and 19 preprogrammed soft keys that enter an entire BASIC word with just one keystroke. And there are two extra soft keys you can program for your own use.

Type in the program below and save it on disk or tape before running it for the first time. If you plan to use it along with the "Automatic Proofreader" to type in a COMPUTE! program, you should load and run Automatic Proofreader at this point. (Of course, this program works on its own, even if you're not using the Proofreader; but when the two are used together, you must install the Proofreader first.)

Now load and run the Softkeys program. It begins by asking you for the starting line number of the program you'll be typing in. Enter that number and press RETURN. Now you're asked to enter the increment (how much the line number increases between one line and the next). Most programs published in COMPUTE! are numbered in increments of ten, but you should always check the program listing to make sure. This number can be changed if the listing later changes to a different increment or skips some line numbers.

Automatic Line Numbering

After you enter this information, Softkeys installs its machine language portion in memory, deletes its BASIC portion, and leaves the computer ready for you to use. On the line below the READY prompt you'll see the first line number followed by a space. Type in the first line from the program listing, then press RETURN to enter it in memory. The computer automatically prints the next line number and waits for you to enter the next line.

If the computer detects an error in the line, it prints the line again and shows where the error occurred. To retype the line, simply press SHIFT-DELETE, type in the correct line number and reenter the line. If you prefer, you can move the cursor back to the old line as usual, correct it, and press RETURN again. Just as in normal screen editing, the cursor can be anywhere on the line when you press RETURN.

The SHIFT-DELETE key combination also lets you perform several other tasks. If the program listing skips line numbers, press SHIFT-DELETE, then enter the new line number and continue typing as before. You can also use SHIFT-DELETE to enter any BASIC command from direct mode. For example, you may want to continue typing a program that you've partially entered and saved. Run Softkeys and answer the prompts as you did when you began typing the program. When the READY prompt comes back, press SHIFT-DELETE, then enter the command you would ordinarily use to load the program. After the program loads, the computer finds the last line number used in the program and automatically continues numbering from that point.

If you press SHIFT-DELETE and then change your mind, press RETURN without typing anything else: The correct line number reappears.

At times you'll need to change the line number increment midway through the program. To do this, press BREAK to disable Softkeys, then enter a USR statement in this format:

U=USR(39300,Kne number,increment)

The increment parameter specifies the desired new increment value, which takes effect after the next line is entered. The line number parameter must be included, but it has no effect. The program continues with the line number in use before the USR. For example, if you've been numbering lines by tens until you reach line 500 and wish to switch to increments of five, get a blank line by pressing SHIFT-DELETE when the computer prints 500, then enter the statement U=USR(39300,100,5). After this, the prompt for line 500 returns, but the next line number is 505.

Softkey Assignments

A softkey is a preprogrammed key combination that lets you print a complete BASIC command with a single keystroke. This program creates a number of softkeys that let you enter commonly used commands quickly and easily. The softkeys are all entered by pressing CTRL along with another key. The accompanying table lists all of the built-in softkeys.

When Softkeys is active, you can enter any of the 19 keywords shown in the table by pressing CTRL along with the indicated key. If you press CTRL-F, the computer prints FOR, and so on. This saves typing time and helps eliminate errors (the computer never types PRIMT instead of PRINT, for example). Note that STRIG and STICK both include a left parenthesis.

Atari Softkeys
Softkey Command

Though 19 softkeys are built into the program, you can add two more of your own. To do this, you'll need to supply new values in the DATA statements in lines 1100 and 1180. Each line contains 10 values. The first value is the keyscan code generated when you press a key. Before you can program your own softkey, you need to know the keyscan code for the key combination you want to use.

For example, let's say you want to program the CTRL-V key combination to print the keyword SAVE followed by a quotation mark (SAVE"). To find the keyscan code for the CTRL-V combination (or any key combination), type the following statements in direct mode (without a line number) and press RETURN:


The computer prints the keyscan code for whatever key or key combination is currently pressed. Try pressing different keys to see the numbers change. The number that appears when you press the desired combination is the keyscan code you need to use. In this case CTRL-V generates the keyscan value 144, so you should replace the first value in line 1100 with 144.

Encoding The Softkey

The next nine values in line 1100 represent the ATASCII values of the characters the computer should print when you press the designated softkey. The ATASCII values for the SAVE" character sequence are 83, 65, 86, 45, 34. Including the keyscan code, that comes to 6 values: Since you don't need the last four values in that line, make them all zeros (this DATA statement must have exactly ten values, even if you don't need to use all ten). When you're finished, line 1100 should look like this:

1100 DATA 144,83,65,86,45,34,0,0,0,0

To use your new softkey, simply rerun the program and try it out. By repeating the process, you can change line 1180 to add another, giving you a total of 21 softkeys. When programming a new softkey, note that you must include a space (character 32) if you want the cursor to move right one space after printing a keyword.

Occasionally, a program requires you to type in a character that requires a CTRL-key combination already used by Softkeys. Disable Softkeys by pressing BREAK, then enter the line. After that's done, you can reactivate the utility with a USR command as described above.

The machine language portion of this program resides in high memory just below the display list in GRAPHICS 0. Use caution if you run a program and later issue the USR command to activate this utility. If the previous program used high memory for any purpose, the computer may crash.

Once you're satisfied with all the softkey assignments, you may want to convert the machine language portion of this program to a binary object file on disk. To do this, first run the BASIC portion, exit to DOS, select the Binary Save option, and save memory from $9984-$9BFl.