Classic Computer Magazine Archive ANTIC VOL. 2, NO. 4 / JULY 1983

PILOT YOUR ATARI

LINES AWAY

by KEN HARMS

PILOT offers some built-in program development tools which our other-lingual friends envy. But one feature I've always missed is the ability to delete more than one line at a time. This month we present a short program which solves that problem and demonstrates yet another interesting feature -- reading the screen.

Type in DELETER and save it on tape or disk. Suppose you've been programming away, and suddenly find yourself with a number of unneeded lines. Make sure you have no line numbers above 9950, then LOAD DELETER and issue the following command:

                                             J:*DELETER

You'll be asked to give the starting line number you wish deleted, the ending number, and the increment by which lines are numbered. Enter these, press RETURN and DELETER will erase lines at the rate of 100 per 8 seconds. If lines are numbered unevenly, enter an increment of one and all lines will be deleted. (It may be slightly faster if you RENumber such a program before LOADing DELETER. This puts all lines on the same increment so fewer numbers are deleted.)

When you're all done, SAVE your program without the DELETER lines. See "PILOT Primer Appendix B, page 151 (disk) or 160 (tape) to find out how to save part of a program.

With all that introduction over, let's find out how the thing works! The first part of the program is devoted to clearing the screen (the ESC-SHIFT-CLEAR character in line 9953), T:yping messages and getting the line numbers and increment (lines 9954 through 9975). Each time a variable is A:ccepted, we check to see that it fits the data we need. For instance, the starting number (#S) cannot be less than zero or larger than 9999 (the highest line number allowed by PILOT). The ending number (#E) must be larger than the starting number (lines 9969 and 9970). Finally, lines 9974 and 9975 make sure that the increment is not less than 0 or larger than 100. The 100 maximum is arbitrary, you can change it to be anything you wish.

Those double sets of conditions in parentheses (lines 9962, for instance) mean if either the condition in the first set OR the condition in the second set is true, execute the command. If the conditions are multiplied, the statement will execute only if condition one AND condition two are both true. To interpret conditional commands, PILOT first evaluates all the conditions. It substitutes a one for each true condition and a zero for each false one. It then does the math linking the commands and if the result is greater than zero, executes the command. You can get fancy with all the signs (a pair of conditions separated by a minus will execute only if the first is true AND the second is false). Experimentation is the rule.

So on to the fun part. The *PRTNTLINES module clears the screen and then prints numbers beginning at the starting number, incremented as directed and ending at the last number to be deleted or after 20 lines have been printed. "DELETE types a J:ump command, then POS:itions the cursor to the top of the screen. Line 9990 is the magic incantation.

In PILOT, values are placed into specific memory locations with the C:@Bn=x command. We read this as "C:ompute at byte n the value x." A byte is computerese for a character. The "n" is the (decimal) address of the byte and "x" is the value we will store in that address. The ATARI uses values at different addresses to control different machine functions such as sounds and colors.

Line 9990 Computes a 13 into address 842. The 13 tells the Atari "when you stop, read your next instruction from the screen rather than the keyboard." Redirecting the flow of information in and out of the computer is easy on the ATARI because it employs a good "operating system, one of the first such systems on the market. So, right after printing a set of line numbers and a J:ump command, and after telling the ATARI to read the screen, line 9991 E:nds the program. And what do you know, the old operating system reads those numbers, thinks they're the same as typing a number without a command on the keyboard and erases each line! When it gets to the bottom of the list it reads a J:*RESTART command and executes it.

Now the first thing *RESTART does is C:ompute a 12 into 842. You're right, the 12 tells the ATARI to turn off the screen reading and start reading the keyboard again. We then check to see if all line numbers have been T:yped and, if not, J:ump to *PRINTLINES to start the procedure all over again.

I left the numbers on the screen to track progress. If you don't like them, you could insert a C:@B instruction to turn the letters blue. Remember to turn with another C:@B or a GR:QUIT.

You can get some real fun from the "842 tango" by using it to modify a program while it turns. Say you want to save a person's name in a program. Ask for the name in a T:ype / A:ccept set of statements which puts it into a variable we'll call $INPUTNAME. Then clear the screen, T:ype a C:ompute statement like this:

                                          C: *NAME = $INPUTNAME

Follow this by a J:ump command on the screen, POS:ition the cursor, Compute the 13 into 842 and E:nd the program. Remember to use a line number in the compute command but no number on the jump. If you have followed the outline of DELETER for a *RESTART, you can SAVE your new program with the name imbedded in it. I'm sure you'll find other uses for "the magic of the 842."

Listing:DELETER.PLT Download / View