Page 1 of 1

OffsetOf() to support array elements

Posted: Mon Oct 21, 2019 2:34 am
by Mistrel
I have a particular structure where I want to know the offset of certain fields:

Code: Select all

Structure SomeStruct
  a1.l
  a2.l
  a3.l
  b1.l
  b2.l
  b3.l
  c1.l
  c2.l
  c3.l
EndStructure
This works OK for OffsetOf() as it is. But these fields are similar enough to be in an array, which doesn't support OffsetOf():

Code: Select all

Structure SomeStruct
  a.l[3]
  b.l[3]
  c.l[3]
EndStructure
It would be nice if we could do this:

Code: Select all

OffsetOf(SomeStruct\b[2])
Instead of card-coding this:

Code: Select all

OffsetOf(SomeStruct\b)+SizeOf(Long)*2
You might think that you could use SizeOf() on the field but this returns the size of the entire array.