update file question

Blitz3D Forums/Blitz3D Beginners Area/update file question

eos(Posted 2003) [#1]
We are working with files and have problems to update a file. We write a file with writeLine command and then we close it. Now we want to update a specific line which is searched using readLine. Then we use writeLine to update the line but the file didnīt update.

Thant you


WolRon(Posted 2003) [#2]
Did you use openfile or readfile? I believe that using readfile prevents writing.

Also I think that if you use writefile, the file will be written over beginning at the beginning of the file.
You could possibly use FilePos and SeekFile to write to the correct area but I don't know how WriteLine works if the new line isn't the same length as the previous line.


eBusiness(Posted 2003) [#3]
To WolRon

Note extreme care needs to be exercised when updating files that contain strings since these are not fixed in length.

--Openfile description--

Can't leave much doubt, right? If the line is not of the right lenght, it will screw up your file. I can think of two solutions: Either write some blanks at the end of each line in order to make them of the same lenght, or rewrite your file every time you want to update it.