Registering property to pascal script

Hi, i got problem with registering property of object.
Im doing it this way:
on CompImport event:

on ExecImport event:

My TPerson look like this:

 `property pAge: Integer read GetAge write SetAge;`

procedure TPerson.setAge(AValue: Integer);
  Age:= AValue;

function TPerson.getAge: Integer;
  Result := Age;

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.

after debugging i found out weird thing:

after trying get age with property (this is in class TPerson.getAge and it returs good age)

but one step ahead in asm

when i try get age with getter:

this is the same but next step in asm:

The “READ” helper should use a var parameter, not a result:

procedure TFormActiveOleControl_W(Self: TForm; T: TWinControl); 
  Self.ActiveOleControl:= T; 

procedure TFormActiveOleControl_R(Self: TForm; var T: TWinControl); 
  T := Self.ActiveOleControl; 

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.
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 thanks for your answer.

Yes. Delphi blurred the lines between public and published. This didn’t use to work but if it works now it’s safe to use.

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?

just a curious side effect. Delphi passes string results as “var” parameter but not integers.

Easiest way is properties yes. That said I’d accept a pull request to add support for class fields for delphi versions that support it.