How to pass object as parameter
bamsey2k1 opened this issue · 3 comments
How to pass Object or Record to PascalScript as function parameter
function Test(Sender: TObject);
begin
//manipulate Sender
end;
Now i'm getting Invalid parameter exception
you mean a cast or methodpointer?:
function Test(Sender: TObject): boolean;
begin
//manipulate Sender or cast it
TForm(sender).tag;
end;
i mean pass TObject from DelphiCode To PascalScript
vParams is array of Variant so it can't held an Object
ProcNo := TPSExec(fExec).GetProc(TbtString('test')); if ProcNo > -1 then TPSExec(fExec).RunProcP(vParams, ProcNo);
is there another way to call function with TObject parameter and return this function Result?
My first reaction asking you why you are storing TObjects in a list of variants, but assuming you have a good reason (maybe to call class methods in PS)! You can't store plain objects as a variant. But you can store interfaces.
You can also cast TObject to Pointer to Integer and store that as Int. But i'm not sure if that's what you really want.
``` for i:=0 to High(varArray) do MyProcedure (TObject(varArray[i]));