Bug? Bug in RandomAccessFile ?

Filippo

Expert
Licensed User
Hi,

This code works in B4a without problems.
B4X:
        Starter.raf.Initialize(File.DirDocuments, "file.txt", False)
        Dim lst As List = Starter.raf.ReadB4XObject(Starter.raf.CurrentPosition)
        Starter.raf.Close
In B4i I have to rebuild "raf" the object every time, otherwise it crashes.
B4X:
        Dim raf As RandomAccessFile
        raf.Initialize(File.DirDocuments, "file.txt", False)
        Dim lst As List = raf.ReadB4XObject(raf.CurrentPosition)
        raf.Close
 

Filippo

Expert
Licensed User
It is more correct to dim a variable before you initialize it again. There is no reason to use a global variable in this case.
So I have no problem, I've only wondered because in B4a, without re-dimensioning the variable, it does not make any problems.
Question, after "raf.Initialize" the current position "raf.CurrentPosition" should not be zero?
 

Filippo

Expert
Licensed User
It is zero.
Unfortunately only with B4a.
For B4i, the variable is not zero if the variable "raf" has been defined as a global variable. :(
 

Filippo

Expert
Licensed User
Top