How can I get the Length of an array with a specific index for example if I have an array like this
TYPE T_PERSON = PACKED RECORD
Example : STRING[40];
Example2 : STRING[10];
Example3 : STRING[5];
END;
example: ARRAY [1..30] OF T_PERSON
and I want to know the Length of example[28]
respectively example[x]
.
Can I get it with LENGTH()
or is there another solution?
If it is an array and you want the number of elements:
high(example)-low(example)+1;
Afaik with Free Pascal and Delphi 4+ length might also work, but don't pin me on that.
If you need the size in bytes, Abelisto is correct and sizeof() is what you want, and it also works on parts of the record (e.g. sizeof(example.example)).
The sum might not add up though if you are not PACKED due to alignment bytes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With