can I create a struct with a “list” in it?

I am working to talk to a dylib and I find that they are passing structs back and forth that include things like:

typedef struct { uint32 theID; uint8 theOtherID; bool isValid; list<ValueID> theValues; } myInfo;

I’m all good until the last entry :wink: Is that a linked list? Do I need to go searching for a struct of ValueID? Do I use a ptr type for that and once I get a ptr to it how do I access it? My C work is all pretty low level working with embedded processors and a few drivers for things, I’ve not seen this particular notation before.

Thanks for any info or pointers to read up!

It’s probably a Ptr to the first element in the list. So declare it as a Ptr in the structure and then use pointer arithmetic to iterate over the list. You’ll need to know the exact size in memory of the ValueID type.

e.g. this method returns a Ptr to the list element at index (the first element is at Index=0):

Function GetListElement(List As Ptr, Index As Integer, ElementSize As Integer) As Ptr
  Dim count As Integer
  Do Until List = Nil
    If count = Index Then Return List
    List = List.Ptr(ElementSize)
    count = count + 1
  Loop
  
  Raise New OutOfBoundsException // invalid index
End Function

thats fantastic, thank you! And you also saved me having to go dig up the linked list structure! I do have the headers that describe the ValueID struct so thats not a problem.