Hi, i got problem with registering property of object.
Im doing it this way:
on CompImport event: CustomClass.RegisterProperty('pAge','Integer',iptRW);
on ExecImport event: RuntimeClass.RegisterPropertyHelper(@TPerson.getAge,@TPerson.setAge,'pAge');
My TPerson look like this:
`property pAge: Integer read GetAge write SetAge;`
procedure TPerson.setAge(AValue: Integer);
begin
Age:= AValue;
end;
function TPerson.getAge: Integer;
begin
Result := Age;
end;
From script when i call myPerson.getAge() - Getter works fine and it return good result.
When i set age with property myPerson.pAge:=28 - it sets person age.
But when i call varAgeOfPerson:=myPerson.pAge - it always return 0.
Also i have string property pName and it works fine for set and get name.
I cant figure out why property pAge always return 0.
Can anyone help?
Thank you so much.
The “READ” helper should use a var parameter, not a result:
procedure TFormActiveOleControl_W(Self: TForm; T: TWinControl);
begin
Self.ActiveOleControl:= T;
end;
procedure TFormActiveOleControl_R(Self: TForm; var T: TWinControl);
begin
T := Self.ActiveOleControl;
end;
So if i have 100 properties with getters i have to rewrite all getters to procedure like this?
And i tried one more think. I move my property from public section to published and with
only one row code i registered it and it works fine. CustomClass.RegisterPublishedProperty('pAge');
And i dont need to set up get function and read function.
It is very comfortable. Can i do this with non-published properties?
And can you tell me why my string property works fine with getter function with result and integer property with result doesnt work ?
And my last question i can register class method, class properties, can a register class fields?
Or only way how to achieve it is with properties?