Seek replacement for binary files
Mar 25, 2023 19:57:20 GMT -5
Post by tyer on Mar 25, 2023 19:57:20 GMT -5
Since it appears that the compiler recognizes the seek keyword, but doesn't know what to do about it (see this thread), I thought I'd try simulating this with a 1-character field definition, opening the file in random mode. My goal is to be able to parse and update arbitrary binary files, starting with the tags in MP3 files uploaded by a user. (I realize that this method may be massively inefficient, but it's s starting point...) So I tried this:
When I run it, I get the following error:
What am I doing wrong, or is there some completely different method I should be trying?
Thanks!
' print a file in reverse order, by seeking from the end
open "Test.dat" for output as #tf
print #tf, "This is a test."
close #tf
open "Test.dat" for random as #tf
field #tf, 1 as char$
build$ = ""
iter = lof(#tf) - 1
while iter > 0
get #tf,iter
build$ = build$ + char$
iter = iter - 1
wend
close #tf
print build$
When I run it, I get the following error:
Runtime Error in program 'twoStyledTables': get #tf,iter
IncompleteNextCountError
What am I doing wrong, or is there some completely different method I should be trying?
Thanks!