I'm having a strange problem using random file access and was wondering if
anyone is aware of why this might be happening. When I write new records to
the file, it seems to take a few seconds before the FILELEN() function to
update with the accurate length. As a test I did the following:
Sub test()
Dim inta As Integer
For inta = 1 To 5
Raffle.TicketsPurchased = inta
Put #20, inta, Raffle
Get #20, inta, Raffle
'Delay (2) Notice this is commented out)
intNumRows = FileLen(App.Path & "\herosraffle.dat") / Len(Raffle)
Say (Str(intNumRows) + " " + Str(Raffle.TicketsPurchased))
Next inta
End Sub
This gave me the following results
1 1
1 2
2 3
3 4
4 5
If I re-run the code with the 2 second delay added in I get
1 1
2 2
3 3
4 4
5 5
Why does it take so long for FILELEN() to update? Is there another way I
can check for how many records are in the file using a different command?
Adding a delay slows down the process this program is performing. Thanks in
advance,
-Keith