Passing object to pascal script

Hello, im new to pascal script and delphi. Im trying to pass object from my app to the script but i cant make it. So im asking experienced people to help me.

this is what i have:

    function ExtendCompiler(Compiler: TPSPascalCompiler; const Name: AnsiString): Boolean;
	CustomClass: TPSCompileTimeClass;
    Compiler.AddDelphiFunction('procedure print(const AText: AnsiString);');

    SIRegisterTObject(Compiler); // Add compile-time definition for TObject

    CustomClass := Compiler.AddClass(Compiler.FindClass('TObject'), TPerson);

    Customclass.RegisterMethod('procedure setAge(AValue: Integer)');
    CustomClass.RegisterMethod('function getAge: Integer');

    Result := True;
    Result := False; // will halt compilation

so i can register my object and create it in my script but how to pass an existing object for example
John: TPerson;
and i want to pass John to my script and in script i want to set his age and so on…

I think its simple question and i hope i will get right answer


Easiest: Expose a function like print, but one that returns your TPerson class.

solved with

but thanks for your idea

THat works too. There’s some more info here: