Adding Function with parm TStringList
How do you pass TStringList in the param list?
If I add 'BuildFileList' as ;
=================================
... (register function)
fsScript1.AddMethod('function BuildFileList(const Path: string; const Attr:Integer; List: TStringList): Boolean', CallMethod,'ctOther','');
...
function TfsScriptDM.CallMethod(Instance: TObject; ClassType: TClass;
const MethodName: String; var Params: Variant): Variant;
begin
if MethodName = 'BUILDFILELIST' then
Result := BuildFileList(Params[0],Params[1],Params[2]);
end;
=================================
Params[2] which is TStringList causes a type mismatch, tried type casting.
Can't get it.
Help?
Thanks,
brian
If I add 'BuildFileList' as ;
=================================
... (register function)
fsScript1.AddMethod('function BuildFileList(const Path: string; const Attr:Integer; List: TStringList): Boolean', CallMethod,'ctOther','');
...
function TfsScriptDM.CallMethod(Instance: TObject; ClassType: TClass;
const MethodName: String; var Params: Variant): Variant;
begin
if MethodName = 'BUILDFILELIST' then
Result := BuildFileList(Params[0],Params[1],Params[2]);
end;
=================================
Params[2] which is TStringList causes a type mismatch, tried type casting.
Can't get it.
Help?
Thanks,
brian
Comments
Adding a function with the class parameter
Since all the parameters are represented as the Variant array type, you need to convert them to objects.
Prog.AddMethod('procedure HideButton(Button: TButton)', CallMethod);
{ the method handler }
function TForm1.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; var Params: Variant): Variant;
begin
TButton(Integer(Params[0])).Hide;
end;