• Please review our updated Terms and Rules here

How can I read this file with BASIC?

jgrillout

Experienced Member
Joined
Jun 5, 2023
Messages
61
I have an IMD from the archive that contains some COBOL source code. I tried to open a file on this disk but get an error

120 OPEN "I",4,"ACCTFILE/DS :3"

? BM Error in 120

I found the error means Bad Mode

I can't figure out how to read data from this file using BASIC

From TRSDOS, i can PRINT the file and i can LIST the file.

PRINT ACCTFILE/DS:3 A
LIST ACCTFILE/DS:3 A PRT

Here is a link to the IMD file and the output from the PRINT and LIST commands
https://u.pcloud.link/publink/show?code=kZj9WUVZQ76IC12Q0mhtTqctqR8AsLiEOdpk

Thanks for any tips
John
 
The files on that disk use variable-length record format. Looks like BASIC won't open such files in sequential mode. I did a quick test and could open the file in direct-access "D" mode:
Code:
10 OPEN"D",1,"ACCTFILE/DS:1"
The Model II BASIC manual will explain how to read data from the file in that mode. It will be a bit complicated as I imagine you'll see the variable length record structure and have to decode that.
 
Thanks gp2000 ! I should look at the manual more often. I would do that but most of the ones I've downloaded don't have links to click to jump to sections and find doe't work because the pages are images no searchable text. I've tried opening the pdf with Microsoft word and its a 50/50 chance it successful.
 
The files on that disk use variable-length record format. Looks like BASIC won't open such files in sequential mode. I did a quick test and could open the file in direct-access "D" mode:
Code:
10 OPEN"D",1,"ACCTFILE/DS:1"
The Model II BASIC manual will explain how to read data from the file in that mode. It will be a bit complicated as I imagine you'll see the variable length record structure and have to decode that.
I downloaded this file "Model 2 & 12 BASIC Reference Manual (1980)(Tandy)(pdf).pdf". Is this the correct manual and chapter i will find the explanation? I didn't see much info on direct access. There is a lot about sequential files and random files. What page should I start at?

Capture.PNG
 
I downloaded this file "Model 2 & 12 BASIC Reference Manual (1980)(Tandy)(pdf).pdf". Is this the correct manual and chapter i will find the explanation? I didn't see much info on direct access. There is a lot about sequential files and random files. What page should I start at?

View attachment 1259752
Seems to be the same chapter I was looking at. I think direct and random access are the same thing; "D" and "R" modes seems to be the same.

What I think you'll be able to do is pull in a 256 bytes of the file at a time into the buffer. Then using FIELD or something pull out the data in strings.

Then, I'm guessing, you'll see the variable record format of the file (the 'V' you see in the directory listing and the TYPE=V at the top of the PRINT output).

The format is simple enough. There's a byte indicating the length of a record, n, followed by n - 1 bytes of data. In other words, the record length includes the length byte. Followed by more records.

I've not tried this before in BASIC so you're into uncharted territory. Or, I should say, territory that hasn't been charted in some time.
 
Back
Top