11-13-2023, 12:38 AM
I need to know because I am using the following method to read/write a fixed length UDT array string to a random record in a file:
Code: (Select All)
' define an array as string.
Type Datatype
Array As String * 16
End Type
Dim DataRecord As Datatype
Dim Array(8) As Integer
Open "datatest.dat" For Random As #1 Len = Len(DataRecord)
' store array.
For L = 1 To 8
Array(L) = L
Next
' put array into UDT string.
For L = 1 To 8
Mid$(DataRecord.Array, (L - 1) * 2 + 1, 2) = MKI$(Array(L))
Next
' put 10 records into file.
For X = 1 To 10
Put 1, X, DataRecord
Next
' get random record from file.
X = Int(Rnd * 10 + 1)
Get 1, X, DataRecord
' get array from UDT string.
For L = 1 To 8
M = CVI(Mid$(DataRecord.Array, (L - 1) * 2 + 1, 2))
Print M;
Next
End