|
Post by dragonjim on Apr 8, 2024 14:35:57 GMT 1
Hi all,
Just doing a straw poll here to find out: Does anyone use Random Access Files any more?
For those who may not recognise the term, they are the ones opened with Open .. For Random and which hold multiple records of one or more fields which can be accessed individually without having to load in the whole file. For a better illustration, see the example from the help file below:
Global age%, firstname$, ct|(5), i%, n1$, n2$, nr|, secondname$ OpenW # 1 Open App.Path & "\Musicians.DAT" for Random As # 1, Len = 52 Field # 1, 24 As firstname$, 24 As secondname$, 4 At(V:age%)
//
For i% = 1 To 5 Read n1$, n2$, age% Lset firstname$ = n1$ Lset secondname$ = n2$ Put # 1, i% ct|(i%) = i% Next i% Close # 1 Data Harold,Faltemeyer,56,Robin,Williams,32,Barry,Manilow,78,Bryan,Adams,52,Demi,Lovato,21
//
Open App.Path & "\Musicians.DAT" for Random As # 1, Len = 52 Field # 1, 24 As firstname$, 24 As secondname$, 4 At(V:age%) For i% = 5 DownTo 1 nr| = Rand(i%) + 1 Record # 1, ct|(nr|) Get # 1 Print "Record" & ct|(nr|) & ": " & Trim(firstname$) & " " & Trim(secondname$) & " aged" & age% Delete ct|(nr) Next i% Close # 1 Kill App.Path & "\Musicians.DAT" // Tidy-up line
|
|
|
Post by (X) on Apr 9, 2024 2:47:58 GMT 1
I'm sure I would if I had a need. It is straight forward and logical.
|
|