CHAPTER 11

STORING ON AND LOADING PROGRAMS FROM CASSETTE TAPE


You can record your programs on a tape cassette using nearly any inexpensive cassette recorder and the recorder cables that come with your Sorcerer. You can also play a recorded program directly into the Sorcerer's mernory.


CHECKING YOUR HARDWARE


First check your recorder to see how its controls work. Some recorders record when you press the REC button, others require that you press the REC and PLAY buttons together. Now take the two cassette recorder cables that come with your Sorcerer and plug them into the MIC and EAR connectors of your recorder; plug the other ends into the MIC and EAR connectors at the rear of the Sorcerer (these connectors are next to the power cord). The two recorder cables are identical, so it doesn't matter which one you hook up to the MIC connectors and which to the EAR connectors. (It is imperative, however, that you plug the MIC cord from the recorder into the MIC connector of the Sorcerer and the EAR cord from the recorder into the EAR connector of the Sorcerer.)

Some recorders have an AUX connector instead of a MIC connector. In such a machine, of course, you use the AUX and EAR connectors in place of the MIC and EAR. Some recorders have both MIC and AUX. On such a recorder, try the MIC connector first. It you cannot got it to work, use the AUX connector instead. You will probably also have to use a different volume setting.

Now check your recorder's tone and volume settings. If these settings are wrong, your programs won't load properly. Each recorder has its own characteristics, and so does each brand of cassette tape. If you don't know the proper settings, try putting the tone at its maximum (treble) and volume at a setting of about half. (For example, set a control knob labeled 1 to 10 at 5.) Then try recording and loading a test program, making adjustments to the controls as needed to get good results.


NOTE

Since most cassette recorders have automatic level control (ALC) for recording, no adjustment is necessary to record programs.


The problems you have, if any, will be in the loading of the program back into the Sorcerer. Once you find a correct setting, use it thereafter, because that setting will always be good for your particular Sorcerer/recorder/tape configuration.

You can use any tape cassette, but note that most cassettes have non-magnetic strips of tape (leader) at each end of the magnetic tape, so make sure there is magnetic tape under the recording head before you try to record a program. (If you cut off even the first little bit of a program you will not be able to load it later.) You will get better results with short cassettes (thirty minutes or less) than with long ones-the longer cassettes have more internal friction, and their tape won't move as uniformly past the recording head. Also, putting too many programs on one tape makes the individual programs hard to find. Many owners of Sorcerers put only one program on each side of a cassette. Tape is cheap, if you accidentally demagnetize a tape or otherwise "blow it up," you'll only destroy a maximum of two programs at a time. If you do put more than one program on a side, you will find it difficult to locate individual programs unless you have a tape recorder with a counter.

Low noise, high frequency tape gives better results than cheaper tape. For best results, we recommend Exidy data cassettes (Part No. DP3001).

Most of the time you will use only one cassette recorder in manual operation. If you want to connect two recorders, you can order a special Serial Cassette Data Cable, Part No DP4005. (Give its name if you order one.) This cable attaches to the 25-pin connector labeled Serial Interface. Not only does the cable permit use of two recorders, it also provides automatic motor control, which means the Sorcerer can start and stop both recorders automatically. Because the Sorcerer can handle two recorders, when you instruct it to play or record a program, you must also tell it whether to use tape unit #1 or tape unit #2. The instruction sheet which comes with the data cable explains how to tell which tape recorder is unit #1 and which unit #2. Of course, if you only attach one recorder (using the two cables that come with the Sorcerer) then that recorder is tape unit #1, and there isn't any tape unit #2.


TO RECORD A PROGRAM


CSAVE is the command to record the program currently in the Sorcerer's memory. The format is:

CSAVE|<program name>|<unit number>|

The Sorcerer is usually not too fussy about where you put spaces when you use Standard BASIC, but notice that if you use the <unit number> option you must leave a space between the name of the program and the unit number. If you don't include the unit number, the Sorcerer uses unit #1. (Another way to say this is that the default value of <unit number> is 1.) The <program name> can be any combination of up to five alphanumeric characters. The Sorcerer does not recognize other characters in program names, and it ignores characters beyond the fifth. If the name is too long or if you use some of the characters other than alphanumerics, you may get the Monitor message ERROR -INVALID PARAMETER and the Monitor prompt >. Don't panic. Type PP, with no space after the PP and you return to Standard BASIC, which notifies you of its resurrection with the READY prompt. Whatever program was in memory will still be there.

Although the Sorcerer can save your program on tape even if you don't include the <program name> option, we recomrnend giving your program a name so you know what you have saved. If you use the <unit number> option you must also use the <program name> option.

Before recording a program, type the entire CSAVE command on the screen but do not hit RETURN. Press the REC and PLAY buttons on your recorder (or the REC button alone, on those recorders that use only one). Make sure that the leader passes the recording head and then hit RETURN. When the Sorcerer finishes recording, it gives you a READY prompt. Wait a few seconds and then stop the recorder. (The wait assures not overlapping into another program, if you record one, and makes certain that you don't cut anything off the end of the one you are saving. You also need a little room between programs to find the next one.) If your recorder has a counter, you may wish to note down the beginning and end numbers of your program.


TO REPLAY A PROGRAM


CLOAD is the command to load a program from the cassette tape into the Sorcerer's memory. This command also wipes out whatever program is currently in memory and resets all variables to 0 (just as does the command NEW). The format is:

CLOAD|<program name>|<unit number>|

As before, you must leave a space between the <program name> and the <unit number>. If you don't specify the unit, the Sorcerer again defaults to unit #1. You may use CLOAD with neither option to load the next program that the Sorcerer comes to on the tape. As before, if you specify <unit number> you must also give a <program name>. If you specify a program name, the Sorcerer does not load any programs until it comes to the one you request, skipping any other programs it encounters.

Before giving the command, rewind the tape to the beginning (or, if you're starting at a specific program, rewind to a few numbers on the counter before where the program starts).


NOTE

Starting too early on the tape is fine. Starting too late causes problems.


First type in the entire CLOAD command and then press the PLAY button on the recorder. Immediately press RETURN. When the Sorcerer finds your program, it tells you so. When it finishes loading, it gives you a READY prompt and you can turn off the tape.

Let's follow the whole process through.


NOTE

The first time you calibrate your Sorcerer/recorder/tape system, use a short program. When you find the correct volume and tone levels, use them thereafter.


Enter this program:

10 REM TEST PROGRAM
20 PRINT "TEST PROGRAM"

Now LIST the program to make sure your Sorcerer has it in memory. If you are using just one tape recorder, type

CSAVE TEST

Press the REC and PLAY buttons simultaneously on your recorder (or just REC if it works that way) and wait until you are sure the leader has passed the recording head. Now hit RETURN. After the Sorcerer records your program it will reply with a READY prompt.


NOTE

Do not rely on the READY prompt during record operations as an indication that all is well. You always get the READY prompt after all the data has been sent, even if it wasn't property recorded.


One way to tell whether or not you have saved a program successfully on tape is to reload it. That has the unfortunate disadvantage of clobbering whatever program you have in memory at the time.

You can verify that you have successfully saved your program on tape without losing the program, by following this procedure:

  1. Use the CSAVE command as previously explained to save the program (which we will call TEST in this explanation) on tape. When you get the READY prompt, do not turn off the recorder.
  2. With the recorder still in record mode, CSAVE your program a second time sho tl after the first, by again typing CSAVE RETURN.
  3. When you get the READY prompt, turn off the recorder and rewind the tape to the beginning.
  4. Use BASIC's BYE command to get into the Monitor.
  5. Start the tape in play mode and type FI RETURN.
  6. The Monitor's F1 (for FILES) command reads every byte on the tape and checks to see if it is saved correctly. You get this message:
NAME    FILE BLCK ADDR GOADDR
  1. If everything is in order, this soon appears:
TEST     |   XXXX 01D5  0000
  1. When your second copy of the file is found, that message repeats, so that what you now see on screen is this:
NAME    FILE BLCK ADDR GOADDR
TEST | XXXX 01D5 0000
TEST | XXXX 01D5 0000
  1. After the read of the second file, this message usually appears, due to "garbage" an the tape after the file:
ERROR - TAPE CRC ERROR
  1. If you got no error message after the first file was read. then you successfully saved the program. (You saved two copies of the program, to make sure it wasn't your program that produced the error message.)
  2. Now use the Monitor command PP RETURN to return to BASIC, where your program will still be intact. You ascertained that the CSAVE was successful without losing what was in memory.

When you get the Sorcerer to record your program properly, wipe out the version of it in memory by giving the command NEW, and give the LIST command to prove to yourself that the program is really gone. (You do this so that when you CLOAD and LIST the program you know that it is not a remnant of a previous operation.) Normally you don't do this, because, when it is time to reload the program into memory, CLOAD wipes out whatever is currently in memory.

Now rewind the tape to the beginning. Type the command

CLOAD TEST

Make sure that the tape counter indicates the tape is a few numbers before the start of the program. (For the CLOAD operation, it's okay to start the tape running on the leader.) Now press the PLAY button on the recorder and press the RETURN on the Sorcerer. If the Sorcerer doesn't like your program, it may respond

ERROR - TAPE CRC ERROR

This is a Monitor message. You know you are in the Monitor because you see the Monitor prompt (>). Type PP to return to BASIC.

When your program successfully loads, you get the READY prompt. If this doesn't happen in a reasonable time (this short a program will fill only a few numbers on the digital counter of the recorder), check all your electrical connections, readjust your recorder's tone and volume controls, rewind the recorder and try again. You will have to reset your Sorcerer.


NOTE

The READY prompt at the end of a CLOAD operation is indication of success.


If the program you request is the first the Sorcerer encounters, you see this message on the screen:

FOUND - TEST  |  XXXX 01D5 0000
LOADING -

The first symbol is a graphic character associated with file type. XXXX is the length of the file (in hexadecimal bytes). 01D5 is the starting address of the program. (All BASIC programs load at 01D5 hex.) 0000 is something called the GO address (unused by BASIC). (You will find more about this in A GUIDED TOUR OF PERSONAL COMPUTING.)

Shortly, this appears:

NAME     FILE BLCK ADDR GOADDR
TEST | XXXX 01D5 0000
READY

If all this doesn't happen in a reasonable time (it takes as long to load a program as to save it), readjust your tone and volume controls and try again. When you do get the proper responses, check your results by giving the command

LIST

If the requested program is not the first one the Sorcerer comes to, it tells you the names of programs it encounters and keeps searching. It prints FOUND and the program name for each program it finds.

You can use CLOAD as a program statement, but when the new program is loaded, the program containing the CLOAD statement is automatically wiped out of memory. Rewind the cassette with the TEST program to the beginning. Type NEW and then enter this program.

10 REM CLOAD PROGRAM
20 PRINT "I WILL LOAD A PROGRAM."
30 CLOAD TEST
40 PRINT "I LOADED IT."

Type RUN, start the recorder running with the PLAY button, and hit RETURN. You get this:

I WILL LOAD A PROGRAM

FOUND - TEST | 002B 01D5 0000
LOADING -
NAME FILE BLCK ADDR GOADDR
TEST | 002B 01D5 0000
READY

Notice that line 40 never executes. Type LIST and there is your old friend, TEST PROGRAM. No trace remains of CLOAD PROGRAM.

By the way, would you like to see what your program looks like in memory? Type BYE RETURNto got into the Monitor. When you see the > prompt, give this command

DU 01D5 0200

for a hex dump of your program. (Your program starts at 01D5 and is 2B hex bytes long.) Fascinating, huh? See A GUIDED TOUR OF PERSONAL COMPUTING for details on the DU command.


SAVING AND LOADING NUMERICAL ARRAYS


The command to save a numerical array is:

CSAVE* <unit number> <array name>

Here you must include the <unit number> and leave a space before the <array name>. (And, of course, you must previously have dimensioned the array.) The command to load a numerical array from a cassette recorder is

CLOAD* <unit number> <array name>

Again you must include the <unit number> and leave a space before the <array name> You must also give a DIM declaration for your array before you try to load it. Otherwise, use this command as you would use CLOAD.

You may use CSAVE* and CLOAD* as program statements.

This program saves an array on tape. Rewind your cassette recorder to the beginning. Enter the program. Type RUN but do not hit RETURN. Start your recorder in its RECORD mode as previously. Wait until the leader passes the recording head and then hit RETURN.

10 DIM AL(2,8)
20 FOR X=0 TO 2:FOR Y=0 TO 8
30 READ A
40 AL(X,Y)=A
50 NEXT Y,X
60 CSAVE* 1 AL
70 FOR X=0 TO 2:FOR Y=0 TO 8
80 PRINT AL(X,Y);
90 NEXT Y,X
100 DATA 1, 2, 3, 4, 5, 6, 7, 8, 9
110 DATA 10, 11, 12, 13, 14, 15, 16, 17, 18
120 DATA 19, 20, 21, 22, 23, 24, 25, 26, 27
RUN
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18
19 20 21 22 23 24 25 26
27

Now type NEW and enter the next program. Rewind the recorder. Type RUN but do not hit RETURN. Start the recorder in the PLAY mode, and then hit RETURN.

10 DIM AL(2,8)
20 FOR X=0 TO 2:FOR Y=0 TO 8
30 PRINT AL(X,Y);
40 NEXT Y,X
50 PRINT
60 CLOAD* 1 AL
70 FOR X=0 TO 2:FOR Y=0 TO 8
80 PRINT AL(X,Y);
90 NEXT Y,X
RUN
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18 19 20 21 22 23 24 25 26 27

Lines 20 to 40 demonstrate that the array is not yet filled. Line 50 loads the array from the tape. Lines 70 to 90 demonstrate that the load is successful.

For a complex program, you need either motor control of the recorder, or a message to the user to start the tape, because you cannot tell precisely how long it will take a program to get to the CSAVE* or CLOAD* statement.

You cannot directly save string arrays on tape, but there are ways around this. One would be to write a subroutine that changes string characters into ASCII numbers and then transforms those ASCII numbers back into string characters. Here is a program that does it.

100 CLEAR 1000
110 DEF FNM(X)=X-256*INT(X/256)
120 INPUT "HOW MANY ELEMENTS IN STRING ARRAY";S:S=S-1
130 DIM S$(S)
140 L=0
150 FOR I=0 TO S
160 PRINT "ENTER ELEMENT #";I+1;
170 INPUT S$(I)
180 M=LEN(S$(I)):IF M>L THEN L=M:REM FIND LONGEST STRING
190 NEXT I
200 N=INT((L+2)/3)-1
210 DIM A(S,N)
220 FOR Z=0 TO S
230 A$=S$(Z):GOSUB 400
240 NEXT Z
250 PRINT:PRINT "START RECORDER GOING IN RECORD MODE.";
260 INPUT " HIT 'RETURN' WHEN READY";ZZ$
270 CSAVE* 1 A
280 PRINT:PRINT "YOUR ARRAY IS NOW STORED ON TAPE."
290 PRINT "REWIND TAPE TO BEGINNING."
300 PRINT "START RECORDER GOING IN PLAY MODE."
310 INPUT "HIT 'RETURN' WHEN REAEIY";,ZZ$
320 CLOAD* 1 A
330 FOR Z=0 TO S
340 PRINT
350 GOSUB 500:S$(Z)=A$
360 PRINT S$(Z);" ";:REM PRINT OUT ARRAY
370 NEXT Z
380 END
399 REM SUBROUTINE TO CONVERT STRINGS TO NUMBERS
400 I=0:L=LEN(A$)
410 FOR K=0 TO N
420 A(Z,K)=0
430 FOR J=1 TO 3
440 I=I+1:IF I>L THEN 470
450 A(Z,K)=256*A(Z,K)+ASC(MID$(A$,I,1))
460 NEXT J,K
470 RETURN
499 REM SUBROUTINE TO CONVERT NUMBERS BACK TO STRINGS
500 A$=" "
510 FOR K=0 TO N
520 Q=A(Z,K)
530 FOR J=1 To
540 B(J)=FNM(Q):Q=INT(Q/256)
550 NEXT J
560 FOR J=3 TO I STEP
570 A$=A$+CHR$(B(J))
580 NEXT J,K

Table of Contents | Prev | Next

The Trailing Edge