Array of lists
Array of lists
How does one define an array of lists when the size of the array is only known @ runtime?
Re: Array of lists
Code: Select all
Structure Lists
MyListDefinition.l
EndStructure
Define NewMap ListMap.Lists()
Debug @ListMap("List1")
Debug @ListMap("List2")
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: Array of lists
I didn't understand the question, but I made an example with an array of lists.
What do you want to define?
What do you want to define?
Code: Select all
EnableExplicit
Structure y
List x.i()
EndStructure
Define Dim Arr.y(0)
Define i
AddElement(Arr(0)\x())
Arr(0)\x() = 1
AddElement(Arr(0)\x())
Arr(0)\x() = 2
ReDim Arr(1)
AddElement(Arr(1)\x())
Arr(1)\x() = 11
AddElement(Arr(1)\x())
Arr(1)\x() = 22
For i = 0 To ArraySize(Arr())
ForEach Arr(i)\x()
Debug Arr(i)\x()
Next
NextRe: Array of lists
tua wrote: Sat Jan 06, 2024 4:29 am How does one define an array of lists when the size of the array is only known @ runtime?
Code: Select all
Structure item_list
List items.s()
EndStructure
Define lists_needed
lists_needed = Random(12, 1) ;number of lists defined at runtime
Dim b.item_list(lists_needed - 1) ;zero based size
Debug ArraySize(b())
Repeat:
lists_needed = Random(12, 1) ; change number of lists defined at runtime
Until lists_needed <> ArraySize(b() + 1)
ReDim b.item_list(lists_needed - 1) ;or Dim b.item_list(lists_needed) to clear / free all previously existing lists
Debug ArraySize(b())
Re: Array of lists
thanks to all - exactly what I was looking for

