11-13-2023, 01:48 AM
Code: (Select All)
CONST NITEMS = 20, ARLEN = 8
Type Datatype
'Array1 field
Var As Integer
'Array2 field
Var2 As Integer
'Array3 field
Var3 As Integer
End Type
Dim DataRecord(1 to NITEMS) As Datatype
Dim As Integer Array1(1 to NITEMS, 1 to ARLEN), Array2(1 to NITEMS, 1 to ARLEN), Array3(1 to NITEMS, 1 to ARLEN)
' store first array "field".
FOR N = 1 TO NITEMS
For L = 1 To ARLEN
Array1(N, L) = L
Next
NEXT
The "Array1" was the "Array" field in the previous example, which was defined as "STRING * 16". The "Array2" and "Array3" were also supposed to be UDT fields. But they are actually arrays independent of the UDT variable. In QB45 and QB64 it has to be done this way whether you like it or not. Otherwise in QB64 you have ```_MEM``` and its association of statements and functions where you don't have to put a static limit on data storage, but is more difficult sometimes to be counting off things by bytes working in this way. Also needing to ask permission from the operating system to allocate a block of memory, and then in the middle of program run, needing to release that memory for other purposes.
It's sloppy but it works.