Hi chen,
PureBasic allows a file to be read from and written to.
As to whether that is workable for you, it depends on what you are doing.
If you are relying on ReadString(), WriteStringN() and the string sizes change, you could have an issue with one file.
eg:
where the <> represents end of line characters (Chr(13) and Chr(10) for windows). Then
Code: Select all
ptr=Loc() ; Storing current position in file
w.s=ReadString() ; Reading string (getting ABC)
If w="ABC"
w="MYABC"
FileSeek(ptr) ; Returning to start of "ABC"
WriteStringN(w) ; Overwriting "ABC<>DE" with "MYABC<>"
EndIf
So this would give you
Clobbering DE of DEF
However if all "fields" read in and written out are going to be of the same type (or actually length) when updated, no problems. Just use Loc() to store the current position in the file so you can FileSeek(toIt) for the write. After the write Loc() is the old position plus the length of the info written. Eg, 4 bytes for a long.
If you are not sure and there is no issue with speed, diskspace, etc, then read from one and write to another. Don't forget to use UseFile(fileNum) before each read and write sequence though, so PureBasic knows which file to read from and which to write to.
Sorry if that was too simplistic. To too obscure.
@}--`--,-- A rose by any other name ..