[futurebasic] Re: [FB] Writing to portions of file

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 1999 : Group Archive : Group : All Groups

From: JoeAtTIME@...
Date: Fri, 14 May 1999 16:28:21 EDT
Open the file for random access like this:

OPEN "R",#1,filename$,recLen,volRefNum

Read your 32 bytes out of the file like this:

posInFile=3200                                    'position in file you want 
to start reading
RECORD #1, posInFile
READ FILE #1, @myString$+1, 32

To write back to the file reset the record pointer and write the data like 

posInFile=3200                                    'position in file you want 
to start writing
RECORD #1, posInFile
WRITE FILE #1, @myString$+1, 32

In a message dated 5/14/99 3:13:47 PM, you wrote:

<<Hi all,

Is it possible to write data to a specific portion of a file without
re-writing the entire file? Let me elaborate:

Let's say I have a 2.7 Mb document. If I want to modify 32 bytes of data in
the middle of the file, I would normally read the entire 2.7 Mb into memory,
modify the data, then re-write the entire 2.7 Mb back to the file.

What I would like to do is:
1. Read only the 32 bytes of interest into memory
2. Modify it.
3. Replace the old 32 bytes with the new.

Can this be done?

Any pointers will be appreciated.