Classic Computer Magazine Archive COMPUTE! ISSUE 26 / JULY 1982 / PAGE 151

Atari Variable Table Refresh And Program Backup

Jon Harding
Rochester, NY

This is the safety net you need to avoid losing hours of programming time when a power failure or a keyboard lockout strikes your Atari.

Writing new programs, especially long ones, usually requires many hours of editing and typing which can lead to two problems: (1) the variable name table grows too long and (2) the editing session may be catastrophically terminated by a keyboard lockup or power failure. Even commercial software may have variable name tables which are larger than necessary. And power failures occur only at the worst possible time: after typing in the 252nd line of that new game you're so anxious to try! The following routine eliminates the first problem and minimizes the losses of the second.

Type in these two programs (but delete REMs to conserve memory), SAVEing the first as "WRKLOAD.SAV" and LISTing the second as "BACKUP.LST." The meaning of the extensions should be clear. These routines will become part of your program, but can be deleted when you've finished typing. Initiate a new program or add to an existing program, already LOADed, by ENTERing "D:BAKUP.LST". After typing and/or editing five to ten lines, type G.32000 < RETURN >. The program in RAM is LISTed to the disk as "WRK," the RAM area cleared, and "WRK" reENTERed. Edit or add more code and type G.32000 again.

This time the old "WRK" is RENAMEd "WRK.BAK," the program in RAM becomes "WRK," and is re-ENTERed. The next time, and thereafter, "WRK.BAK" is deleted, "WRK" becomes "WRK.BAK," and the program in RAM becomes "WRK" (and is re-ENTERed).

This procedure provides father-son (mother-daughter) backup and keeps the variable name table as small as possible. When you finish a session, type G.32000 once more to save the latest changes in "WRK." When you start a new session just type ENTER"D:WRK" and you pick up where you left off. If you use this routine to back up other programs on your disk, be sure to save the latest version by its proper name, e.g. "D:GASBILL.UTL." You could also delete the "WRK" files before using the routine on another program, but it's not necessary since they will be replaced anyway.

The beauty of this routine is that it only takes a short command to invoke and can't be started by the program in RAM because of the STOP at 31998. The XIO... code is the special I/O command, explained on page 29 of the Atari BASIC Reference Manual which allows you to access DOS utilities without calling DOS, among other things.

Other Possibilities

More generally, this scheme suggests the possibility of a disk with many short utility routines which can be SAVEd for use by themselves or LISTed for use during program writing/editing. Examples might include: listing the disk directory to the screen (without calling DOS), printing the disk directory, a screen viewing of a dumped machine language program, and hex to decimal conversion.

A note of caution: if you write a program which will reside in RAM with the program you're working on, it must be complete within itself. In other words, when execution is completed, everything defined must be undefined (variables, dimensions, arrays), all devices OPENed must be CLOSEd, and there must be an END. (The CLR command takes care of undefining anything DIMensioned and clears all variables.) The closing statement of such a routine should look like this: lineno CLOSE #1:CLR:END.

Program 1.

32039 REM ****************************
32040 ENTER ":WRK"
32041 REM ****************************

Program 2.

31997 REM *********************************************
32000 TRAP 32010 : XIO 33, #1, 0, 0, "WRK, BAK" : TRAP 40000
32010 TRAP 32020 : XIO 32, #1, 0, 0, "D : WRK, WRK.BAK" : TRAP 40000
32020 LIST "D : WRK" : RUN "D : WRKLOAD.SAV"
32050 REM ***************************************************