as I found out in an other topic there is no possibility to calculate the offset of static array members other than creating the difference to the first element in the structure if you use a dummy variable or an already existing instance of a variable with that structure.
This of course works:
Code: Select all
Structure foo
bar.l[4]
EndStructure
Debug OffsetOf(foo\bar) ; = 0
Code: Select all
Structure foo
bar.l[4]
EndStructure
Debug OffsetOf(foo\bar[2])
Code: Select all
Structure foo
bar.l[4]
EndStructure
Define dummy.foo
Debug @dummy\bar[2] - @dummy ; = 8
Code: Select all
Structure foo
bar.l[4]
EndStructure
Debug OffsetOf(foo\bar) + 2 * SizeOf(foo\bar) ; = 32
Code: Select all
Structure foo
bar.l[4]
EndStructure
Debug TypeOf(foo\bar) ; = #PB_Long
Conclusion
So it is not possible to calculate the correct offset to a certain static array member when you want to use it together with SortStructuredList for example. Instead you need to use magic numbers or you have to know the type of your field in other places in your code or you need a dummy variable to be able to calculate it more accurate.
The simplest solution in my opinion to solve that problem would be to add the possibility for square brackets within the structure member path like I demonstrated it in the second code snippet.