JaedenRuiner
06-19-2007, 09:29 AM
Hello,
Given a file opened as such:
open sFileName for Binary Access Read Write As #FileNum
You can easily use the Seek, Get, and Put statements to access the binary data of the file. So you may have to improvise your own file format, but it works to achieve the simplistic end. However, the Put statement just writes the data to the file without any position checking. So:
Dim S as String
S = "Hello World"
Put #FileNum,,Len(S)
Put #FileNum,,S
Write a length integer and a string to the file, total size=13 bytes. But now, i decide to Seek #filenum,1 (to go to the start of the file) and say now I'm writing a smaller string:
S = "My World"
Seek #FileNum,1
Put #FileNum,, len(S)
Put #FileNum,,S
Total Size written: 10 bytes
But the file size is still 13 bytes from the previous write. There are 3 extraneous characters that aren't doing anything. Is there any way (built in) to truncate the file down to the current position, sort of a clear or purge that eliminates all data after a certain point and resets the filesize/eof?
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
Given a file opened as such:
open sFileName for Binary Access Read Write As #FileNum
You can easily use the Seek, Get, and Put statements to access the binary data of the file. So you may have to improvise your own file format, but it works to achieve the simplistic end. However, the Put statement just writes the data to the file without any position checking. So:
Dim S as String
S = "Hello World"
Put #FileNum,,Len(S)
Put #FileNum,,S
Write a length integer and a string to the file, total size=13 bytes. But now, i decide to Seek #filenum,1 (to go to the start of the file) and say now I'm writing a smaller string:
S = "My World"
Seek #FileNum,1
Put #FileNum,, len(S)
Put #FileNum,,S
Total Size written: 10 bytes
But the file size is still 13 bytes from the previous write. There are 3 extraneous characters that aren't doing anything. Is there any way (built in) to truncate the file down to the current position, sort of a clear or purge that eliminates all data after a certain point and resets the filesize/eof?
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner