Many times a program is written that requires the input of data that is then used in some manner. If you then turn your computer off, the program and the data are lost, unless you SAVEd the entire program to tape or made a hard copy of the output of your program. However this leads to other problems: the hard copy can be lost or at the least must be re-entered; the tape copy can only be used to make a new hard copy, you can not add more data to the variables already established. If you are SAVEing a long program (the one that led to this article was 18K) over and over it can begin to use up a tremendous amount of tape space.
It is possible to SAVE specific variables on the 2068, but they must be DIMensioned arrays, and must be SAVEd one at a time. The Membership list program, for example, uses 12 diferent arrays, requireing a tedious series of SAVEs – and even then, several important counters cannot be transferred. There is another solution that has been developed with the help of Mark Fisher. This involves the use of the DELETE token. When you enter “DELETE ,'””, the program is deleted or wiped out of the memory. (Since the screen memory is independent of the program area, listings that appear on the screen when you enter “DELETE,” will remain until you next press ENTER, even though the program they refer to has been erased.) What is not DELETEd is the variable section. One note of caution: if you hit CLEAR and ENTER, the variables will be gone. One possible subroutine is listed below.
10 REM saving variables
20 CLS: PRINT AT 3, 4; "Do you want to save your inputs to tape? Y/N"
30 PRINT AT 11,4; "Entering Y will cause the program to be DELETED----- please verify that your output is correct."
40 INPUT A$
50 IF A$="" OR A$=" " THEN GO TO 40
60 IF A$="Y" THEN GO TO 80
70 IF A$="N" THEN GO TO 130
80 PRINT AT 15,0; "Enter file name (max 10 chars) "
90 INPUT B$
100 PRINT AT 16,2; "File name; "; FLASH 1 ; B$
110 PRINT AT 13,2; "Enter SAVE (name of file) "
120 DELETE,
130 RETURN
If you ENTER “Y” then the name of the file, the subroutine will delete the entire program and give a report code “C Nonsense in BASIC”. The name that you wish to give your data will remain on the screen. It is now necessary for you to enter SAVE “name of file” and follow the normal routine for SAVEing and VERIFYing the data. If you plan to continue to use your computer after SAVEing data in this manner then press CLEAR and ENTER to eliminate the variables. Failure to do so will foul up the next program that you enter.
[By changing line 120 to “120 DELETE 140, :SAVE B$“, the subroutine will delete everything but itself, and perform the SAVE automatically. When you write the program that is to use this data, there will be some special considerations; as lines MERGEd from tape will overwrite existing lines, it is necessary to avoid conflict between the master program and the subroutine fragment that was SAVEd with the variables. ed.]
When you write your master program you will have to include a subroutine to reload the data that you have already SAVEd. The routine listed below is one possibility.
140 REM Merge old variables
150 CLS: PRINT AT 7,6; "Enter name of file";AT 8,3; "containing names to";AT 9,10;"be loaded"
160 INPUT C$
170 PRINT AT 11,3;"File: ";C$
180 PRINT AT 13, 3;" START RECORDER AND WAIT UNTIL PROGRAM IS LOADED. PROGRAM WILL START AUTOMATICALLY AFTER A SHORT DELAY"
190 MERGE C$
200 RETURN
The delay varies depending upon the length of the program. I do not know what the computer is doing during the delay. I would appreciate it if someone who knows what is going on would let me know. I would be glad to answer any question about this article that you may have.
Products
Media
Image Gallery
Source Code
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.