Adding Function with parm TStringList

edited 12:44PM in FastScript
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

Comments

  • edited 12:44PM
    See the documentation:

    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;

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.