Page 1 of 1

SizeOf to work on structure arrays

Posted: Sun Oct 10, 2010 1:32 am
by Mistrel
I can still get the size of the array using a workaround. But shouldn't this work with SizeOf on the structure entry itself?

Code: Select all

Structure TestStruct
  Entry.s[16]
  List TestList.l()
EndStructure

TestStruct.TestStruct

;/ Output 0
Debug ListSize(TestStruct\TestList())
AddElement(TestStruct\TestList())

;/ Output 1
Debug ListSize(TestStruct\TestList())

;/ Works fine
Debug SizeOf(TestStruct\Entry)/SizeOf(String)

;/ Not recognized as an array
ArraySize(TestStruct\Entry)

Re: SizeOf to work on structure arrays

Posted: Sun Oct 10, 2010 9:54 am
by srod
ArraySize() is for dynamic arrays. You are using a static array in which ArraySize() is not required because, well, the array is static and is not subject to a re-dimension at any time! The following works fine.

Code: Select all

Structure TestStruct
  Array Entry.s(16)
  List TestList.l()
EndStructure

TestStruct.TestStruct

Debug ArraySize(TestStruct\Entry())

Re: SizeOf to work on structure arrays

Posted: Sun Oct 10, 2010 11:17 am
by Mistrel
I see. I didn't realize you could use the "Array" keyword in structures. Some features are still too new for me! :shock:

Re: SizeOf to work on structure arrays

Posted: Sun Oct 10, 2010 6:40 pm
by Thorium
Mistrel wrote:I see. I didn't realize you could use the "Array" keyword in structures. Some features are still too new for me! :shock:
Actualy this is a brand new feature. ^^

Re: SizeOf to work on structure arrays

Posted: Sun Oct 10, 2010 11:49 pm
by Mistrel
Yes, I'm still not up to speed. I'm still mostly in in 4.31-mode. :wink: