[fpc-pascal] Iterating over elements from GetDynArrayProp

Hairy Pixels genericptr at gmail.com
Sat Oct 15 05:34:40 CEST 2022


How can I iterate over the pointer that is returned from GetDynArrayProp? I tried to cast it as a dynamic array of the element type but calling Length() on the returned value gave garbled data.

For example with a property of the type “array of TObject":

type
  TObjectArray = array of TObject;
  PObjectArray = ^TObjectArray;
var
  ObjectArray: PObjectArray;
begin
  ObjectArray := PObjectArray(GetDynArrayProp(AObject, PropertyInfo));
  writeln(Length(ObjectArray^));
end;

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list