PDA

View Full Version : File read & write, MBASIC on CP/M



smp
August 5th, 2017, 10:26 AM
Hello all,

A couple of years ago, I laboriously typed a BASIC program into my computer from the March 1983 edition of 80 Micro. The program is a tiny LISP written in BASIC for the TRS-80 Model I, II, 16, supposedly compatible with both cassette and disk BASIC. I was able to get the program into my Color Computer and get it running back then at the time, but I never explored the SAVE and LOAD functions.

Anyway, I dug this program out a couple of weeks ago, and I've been able to make only one minor mod (get rid of the CLS statement) and I have the program running on MBASIC on CP/M.

This time around, I re-discovered that the LISP is supposed to be able to SAVE and LOAD. Logical, especially because LISP is one of those kernel languages that you write your own routines that you wish to have, and it is necessary to be able to save those routines somewhere and be able to get them back without typing them all in again, and again...

So, today I gave it a try. Of course, I got an error message "Illegal Function Call in 4500" and the program bombed back out to MBASIC. I get the error in line 4500 for the SAVE command, and in line 4600 for the LOAD command.

I took a look at the code, and I found that these two lines attempt to save or load a variety of arrays that the tiny LISP uses to save user defined input. Sounds good. The interesting thing is the code is using the statements:

SAVE

PRINT#-1,FE,PE,A5 : FOR J=2 TO FE : PRINT#-1,FP(J) : NEXT : FOR J=49 TO PE : PRINT#-1,OB$(J),PT(J) : NEXT : FOR J=1 TO A5 : PRINT#-1,LM(J),PL(J) : NEXT

LOAD

INPUT#-1,FE,PE,A5 : FOR J=2 TO FE : INPUT#-1,FP(J) : NEXT : FOR J=49 TO PE : INPUT#-1,OB$(J),PT(J) : NEXT : FOR J=1 TO A5 : INPUT#-1,LM(J),PL(J) : NEXT

The illegal function calls that MBASIC is complaining about are the PRINT#-1, and the INPUT#-1 statements.

Further perusal of the code finds no OPEN or CLOSE statements anywhere. I would have expected them to be there somewhere to open a file in advance for I/O and close it when done. So this leads me finally to my question: On the Radio Shack Model I BASIC, were the PRINT#-1 and INPUT#-1 statements used to automatically imply file I/O? I have a vague recollection that on the Radio Shack machines PRINT#-1 may have implied cassette output and PRINT#-2 may have implied printer output. If anyone can verify this for me, I would appreciate it.

If I can get this completely working properly, I will be glad to share the code with anyone else who might like to play with it.

Thanks for listening...

smp

krebizfan
August 5th, 2017, 11:33 AM
PRINT #-1 goes to the cassette. Level 1 BASIC which used PRINT # does an implicit open and close. https://archive.org/details/Level_1_Users_Manual_1977_David_Lien Appendix A for description.

smp
August 5th, 2017, 12:27 PM
PRINT #-1 goes to the cassette. Level 1 BASIC which used PRINT # does an implicit open and close. https://archive.org/details/Level_1_Users_Manual_1977_David_Lien Appendix A for description.

Thanks a million, krebizfan. Greatly appreciated. Thanks very much for the link, also.

smp