[Coco] APPENDING TO A FILE IN RSDOS ?

coco at jechar.ca coco at jechar.ca
Fri Mar 31 12:51:02 EDT 2023



Thanks I will work on a new version incorporating this new info.

On 2023-03-28 11:04, William Astle via Coco wrote:
> You can't just assign to FIELDed variables. Doing so breaks the
> association with the random file. You have to use LSET or RSET.
> 
> Also, just opening a file in "R" or "D" (exactly the same) mode should
> create a file that doesn't exist. There's no need for your seed file
> or a "CREATE" command.
> 
> On 2023-03-28 08:51, coco--- via Coco wrote:
>> To: All
>> 
>> I continue to have issues with file manipulation in RS-DOS.
>> 
>> My current objective is to add a 100 space characters to the end of a 
>> data file that consists of single byte fields.
>> 
>> So that given a file X on drive 0 running this program should create
>> a file PADDED.DAT on drive 1 who's contents are the contents of X:0 
>> plus
>> 100 blank spaces at the end of the file the following code fails I 
>> don't
>> understand what I am doing wrong.
>> 
>> To set things up you need a file "X" with no extension on drive 0 and
>> a File called SEED.DAT on drive 1. Then at the OK prompts type
>> 
>> OK DRIVE 1
>> OK RUN "PD.BAS"
>> FILE NAME? X
>> 
>> where the source for PD.BAS is shown below.
>> 
>> 20 'A ROUTINE TO PAD THE DATA WITH 100's OF SPACES.
>> 50 PRINT "FILE NAME";
>> 60 INPUT F$
>> 70 COPY F$+":0" TO F$+".DAT:1"
>> 80 OPEN "R",#1,F$,1
>> 90 MX=LOF(1)
>> 95 PRINT MX;"BYTES FOUND."
>> 98 PRINT"READY";
>> 99 INPUT R$
>> 100 CLOSE #1
>> 101 'since I found no CREATE command I try adding to a single byte 
>> file'
>> 105 COPY "SEED.DAT:1" TO "PADDED.DAT:1"
>> 110 OPEN "D",#2,"PADDED.DAT:1",1
>> 120 FIELD #2,1 AS DT$
>> 180 OPEN "D",#1,F$,1
>> 190 FIELD #1,1 AS ST$
>> 200 FOR I=1 TO MX
>> 210 :GET #1,I
>> 220 :DT$=ST$
>> 225 :PUT #2,I
>> 230 NEXT I
>> 235 J=MX+1
>> 238 K=J+100
>> 240 FOR I=J TO K
>> 245 :DT$=" "
>> 250 :PUT #2,I
>> 260 NEXT
>> 270 CLOSE #2
>> 280 CLOSE #1
>> 300 END
>> 
>> If someone knows an easier way that works in RS-DOS or what is wrong 
>> with
>> my code I would like to hear from you.
>> 
>> Charlie.
>> 


More information about the Coco mailing list