|
Post by Splief on Dec 2, 2023 16:32:48 GMT
While reading records from a random access file in sequence for 710 runs via loop and GET statements, then trying to PUT a specific record at 711 (last record read and still at that position in file) while the file is still open, it always tries to write to 712, even if the record number is stated. Tried a few methods to get it to write to the correct record and the only solution was to close the file and re-open it. Bug or just something that always has to be worked around? Didn't effect my program any by having to close the file and reopen it, but still.....
|
|
|
Post by bplus on Dec 2, 2023 17:07:36 GMT
It often helps to have another pair of eyes look over the code. If there is a ton, just capture the essentail parts in a snippet. Only need enough to replicate the error or "bug".
|
|
|
Post by Splief on Dec 2, 2023 23:35:37 GMT
It often helps to have another pair of eyes look over the code. If there is a ton, just capture the essentail parts in a snippet. Only need enough to replicate the error or "bug". I'll see if I can simplify the code yet preserve the error and post here. The loop in question is pretty extensive.
|
|
|
Post by plus on Dec 3, 2023 2:06:44 GMT
You just might find the problem yourself as you tear into it and capture it's essence
|
|
|
Post by bplus on Dec 11, 2023 0:10:42 GMT
A very quick demo using Random Access for storing and retrieving data in a record form.
_Title "Simple Random Access demo" ' bplus 2023-12-10
Type RecordType recNum As Long comment As String * 50 End Type
'Make a record: Dim Shared Record As RecordType, lenRecord&, nRecs& lenRecord& = Len(Record)
' start up a new data file If _FileExists("Simple Random Data.dat") Then Kill "Simple Random Data.dat" Open "Simple Random Data.dat" For Random As #1 Len = lenRecord&
'Store 10 records into fresh clean file: For i = 1 To 10 Record.recNum = i Record.comment = "This is record #" + _Trim$(Str$(i)) Put #1, i, Record Next
' check records nRecs = LOF(1) / lenRecord& Print "number recs:"; nRecs For i = 1 To nRecs Get #1, i, Record Print Record.recNum; ","; Record.comment Next Print " First 10 records starts the file." Print "We will add some more at every other record starting at 11." Print "zzz press any... " Sleep _KeyClear
' add more records For i = 11 To 20 Step 2 Record.recNum = i Record.comment = "This is record #" + _Trim$(Str$(i)) Put #1, i, Record Next Print "Every other record added from 11 to 19," Print "zzz press any to see the file now... " Sleep Cls
' Final check records nRecs = LOF(1) / lenRecord& Print "number recs:"; nRecs For i = 1 To nRecs Get #1, i, Record Print Record.recNum; ","; Record.comment Next
Close #1
|
|
|
Post by plus on Dec 11, 2023 0:18:08 GMT
While reading records from a random access file in sequence for 710 runs via loop and GET statements, then trying to PUT a specific record at 711 (last record read and still at that position in file) while the file is still open, it always tries to write to 712, even if the record number is stated. Tried a few methods to get it to write to the correct record and the only solution was to close the file and re-open it. Bug or just something that always has to be worked around? Didn't effect my program any by having to close the file and reopen it, but still..... Reading this over again, I am wondering if you think Random Access knows what record you want to Get or Put, if you don't specify? It does not retrieve files in sequence like Input access does. Always best to specify which record to Get or Put.
|
|