Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Virtual Arrays
#6
Yes same amount of bytes for each record which could be divided into fields numeric type and/or fixed length strings.

We did setup an RA for Dictionary words and definitions for PhilOfPerth, simple word and definition per record, try search?

Oh I might have quickie example:
Code: (Select All)
_Title "UDT to Random Access File Test" ' b+ 2021-12-24
Type Image
    As String * 255 Text, FileName
    As Long SzX, SzY, PosX, PosY
End Type

Const SW = 1000, SH = 700
ReDim As Image TheItem(1 To 100), TheRecord

TheItem(1).Text = FakeText$(255)
TheItem(1).FileName = FakeText$(255)
Print TheItem(1).Text
Print Len(TheItem(1).Text)
Print TheItem(1).FileName
Print Len(TheItem(1).FileName)
Print "zzz"
Sleep

'make fake data to file
For i = 1 To 100
    TheItem(i).Text = FakeText$(255)
    TheItem(i).SzX = 100 + Rnd * 20
    TheItem(i).SzY = 70 + Rnd * 14
    TheItem(i).PosX = Rnd * (SW - TheItem(i).SzX)
    TheItem(i).PosY = Rnd * (SH - TheItem(i).SzY)
    TheItem(i).FileName = FakeText$(255)
Next

Open "Data Dump.RA" For Random As #1 Len = Len(TheRecord)
For i = 1 To 100
    'odious and tedious is this
    TheRecord.Text = TheItem(i).Text
    TheRecord.SzX = TheItem(i).SzX
    TheRecord.SzY = TheItem(i).SzY
    TheRecord.PosX = TheItem(i).PosX
    TheRecord.PosY = TheItem(i).PosY
    TheRecord.FileName = TheItem(i).FileName
    Put #1, , TheRecord
Next
Close #1
Print "Data File Ready"

' OK we got data filed! Now can we get it back
Open "Data Dump.RA" For Random As #1 Len = Len(TheRecord)
For i = 1 To 100
    Cls
    Get #1, i, TheRecord
    Print "Record Number:"; i
    Print "Text: "; TheRecord.Text
    Print "SzX:"; TheRecord.SzX
    Print "SzY:"; TheRecord.SzY
    Print "PosX:"; TheRecord.PosX
    Print "PosY:"; TheRecord.PosY
    Print "FileName:"; TheRecord.FileName
    Print " zzz..."
    Sleep
Next
Close #1

Function FakeText$ (lengthh)
    BlankString$ = Space$(lengthh)
    fini = Int(Rnd * 255) + 1
    For i = 1 To fini
        Mid$(BlankString$, i, 1) = Chr$(Rnd * (96 - 32) + 32)
    Next
    FakeText$ = BlankString$
End Function
b = b + ...
Reply


Messages In This Thread
Virtual Arrays - by Dimster - 12-15-2024, 01:19 PM
RE: Virtual Arrays - by bplus - 12-15-2024, 02:58 PM
RE: Virtual Arrays - by madscijr - 12-16-2024, 01:24 PM
RE: Virtual Arrays - by Dimster - 12-15-2024, 04:06 PM
RE: Virtual Arrays - by Pete - 12-16-2024, 12:14 AM
RE: Virtual Arrays - by bplus - 12-16-2024, 03:29 PM
RE: Virtual Arrays - by madscijr - Yesterday, 03:49 AM
RE: Virtual Arrays - by Dimster - 12-16-2024, 04:30 PM



Users browsing this thread: 5 Guest(s)