Page 1 of 1

Help required with packer related problem

Posted: Mon Apr 28, 2003 2:10 pm
by chris_b
here's my simple code to test writing some numbers to a file, packing the file, and then retrieving the numbers from the packed file:

Code: Select all

Dim array.l(8)

Debug("original values")

For f=1 To 8
array(f)=Random(1000)
Debug(array(f))
Next

CreateFile(0, "test")
UseFile(0)

For f=1 To 8
WriteLong(array(f))
Next
CloseFile(0)

CreatePack("test.packed")
AddPackFile("test")
ClosePack()

OpenPack("test.packed") 
memaddr=NextPackFile() 
ClosePack() 

Debug("retrieved values")

offset=0
For f=1 To 8
Debug(PeekL(memaddr+offset))
offset=offset+4
Next

End
But the first number retrieved with PeekL is wrong. Can anybody please explain why? am I doing something wrong?

Posted: Mon Apr 28, 2003 3:10 pm
by Fred
ClosePak() free the memory allocated previously by all the pack commands. So do it only when it's done...

Posted: Mon Apr 28, 2003 10:29 pm
by chris_b
:oops: doh! (well, at least I didn't embarass myself by posting in the bug reports forum!)

Thanks Fred!