The tdwsUnit declares a property of type TObject, as well as a getter and a setter. An instantiated object shall be stored in an "object store" on the Delphi side. The goal is to transport the object from script A to script B, where script A, when run, creates and stores the object on the Delphi side and script B, when run (same Delphi process) shall read the object from the Delphi side and use it.
Var ObjectStore : TObject;
procedure TDWSLibTools.TApp_GetObject(Info: TProgramInfo; ExtObject: TObject);
begin
// How to return object in ObjectStore?
<ResultOfThisGetter> := ObjectStore;
end;
procedure TDWSLibTools.TApp_SetObject(Info: TProgramInfo; ExtObject: TObject);
begin
// How to access the object in parameter named "Value"?
ObjectStore := Info.Vars['Value'].Get?????
end;
And: Even when done correctly, will the object "survive" between the script runs?
You can expose any Delphi object instance to any script, so there shouldn't be a problem with creating a Delphi object in one script and accessing that object from another script.
It sounds like your object is initially being created from the script. I'm assuming that this object is declared on the Delphi side and the class type then exposed to the script somehow - e.g. via a
TdwsUnitcomponent.For example on the Delphi side you have a
TDelphiClassdeclared and you have a corresponding script class calledTScriptClass. I'm further assuming that you have declared a TApp script class (e.g. in aTdwsUnit) with an Object property so the script side API looks something like this:Now, as far as I can tell you are just asking how to implement the
GetObjectandSetObjectTdwsUnitevent handlers on the Delphi side. In the following example I assume that yourObjectStorevariable if of the typeTDelphiClass(to make it more obvious where I reference it):