View Full Version : file_seek question
sandyrepope
26-01-2008, 00:56
Situation is: a file is opened binary. file_seek is used to set the file pointer to the 14th byte in the file. My question is: will the next read get the 14th byte or the next one which would be the 15th byte?
Thanks
Sandy
Michael Clease
26-01-2008, 02:16
When you File_seek and then File_Get it reads from the seek position not the next character.
try this
Make a text file containing the string 1234567890ABCDEF
'
' Test.txt = 1234567890ABCDEF
'
'
USES "FILE"
DIM FileHandle as DWORD
DIM FileName as STRING
DIM Char as STRING
DIM n AS DWORD
FileName = APP_SCRIPTPATH + "test.txt"
FileHandle = FILE_OPEN(FileName, "BINARY")
n = FILE_Seek(FileHandle, 8)
Char = FILE_GET(FileHandle, 1)
Msgbox 0, Char
n = FILE_CLOSE (FileHandle)
you should get a message box that show the number 8.
ErosOlmi
26-01-2008, 09:56
Created specific forum for FILE module.
Thanks for the help Abraxas ;)
Ciao
Eros
sandyrepope
26-01-2008, 16:08
Thanks, Abraxas. I understand now. No wonder my program was acting up. My file_seek was off by one. Now it works like it should.
Thanks
Sandy
Michael Clease
27-01-2008, 11:17
No problem.
One tip I would give you is, if you cant work out how to use a keyword or think you are using it incorrectly, make a small bit of code like I did, just to prove it. That way you can seperate it from you main code which could be quite large.
thanks