daver2
10k Member
It still doesn't solve the 'mystery' of how to programmatically create, write and read files. There must be some way of specifying the record size when creating (opening) the file for output.
Dave
Dave
All that is needed to set the record size is to place a comma at the end of the OPEN statement followed by the record length. If the value is 0 or 256 or left out, then the record size is 256 bytes unless done with sequential output which gives a record length of 1*. Note that "D" mode at least won't work if the file is opened with a different record length than used to create the file.It still doesn't solve the 'mystery' of how to programmatically create, write and read files. There must be some way of specifying the record size when creating (opening) the file for output.
Dave
10 OPEN "R",1,"FILE/ABC:1",256
20 FIELD #1,128 AS A$,128 AS B$ ' A$ and B$ now point to the record buffer
30 GET #1,1 ' reads a 256 byte record into A$ and B$
40 PRINT A$;B$
50 CLOSE #1
10 OPEN "R",1,"FILE/TXT:1"
20 FIELD #1,128 AS A$,128 AS B$ ' A$ and B$ now point to the record buffer
30 LSET A$=STRING$(128,"A") ' copy string data to A$ without changing its data pointer
40 LSET B$=STRING$(128,"B") ' copy string data to B$ without changing its data pointer
50 PUT #1,1
60 CLOSE #1
Looked at some of my old printouts and they are pretty much the same as above.Record size only applies to "R" mode, which uses FIELD/GET/PUT for I/O. (ISTR it also defaults to 256 if not specified.) It goes something like this, check the manual to confirm:
Code:10 OPEN "R",1,"FILE/ABC:1",256 20 FIELD #1,128 AS A$,128 AS B$ ' A$ and B$ now point to the record buffer 30 GET #1,1 ' reads a 256 byte record into A$ and B$ 40 PRINT A$;B$ 50 CLOSE #1
Also you need to use LSET and RSET to assign values to A$ and B$ before using PUT, so they stay pointed to the record buffer. Something like:
Code:10 OPEN "R",1,"FILE/TXT:1" 20 FIELD #1,128 AS A$,128 AS B$ ' A$ and B$ now point to the record buffer 30 LSET A$=STRING$(128,"A") ' copy string data to A$ without changing its data pointer 40 LSET B$=STRING$(128,"B") ' copy string data to B$ without changing its data pointer 50 PUT #1,1 60 CLOSE #1