CBuilder examples of AddMethod

edited 8:22PM in FastScript
Can anyone provide an example of using AddMethod under CBuilder?

My apologies, I am not familiar with Delphi at all and I am not able to convert the example in the rs_en.rtf from Delphi to C++.

Thanks

Comments

  • edited 8:22PM
    //

    #include <vcl.h>
    #pragma hdrstop

    #include "Unit1.h"
    //
    #pragma package(smart_init)
    #pragma link "fs_icpp"
    #pragma link "fs_iinterpreter"
    #pragma link "fs_ipascal"
    #pragma link "fs_ijs"
    #pragma resource "*.dfm"
    TForm1 *Form1;
    //
    __fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
    {
    }
    //
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    fsScript1->Parent = fsGlobalUnit();
    //I Think It's a bug! sorry for my poor English
    fsScript1->AddMethod("void Test(a:string, b:string)",CallMethod);
    fsScript1->Lines->Text = "{ Test(\"1234\",\"5678\");}";
    if(fsScript1->Compile())
    fsScript1->Execute();
    else
    ShowMessage(fsScript1->ErrorMsg);
    }
    //
    Variant __fastcall TForm1::CallMethod(TObject * Object, TMetaClass * MetaClass, AnsiString FunName, Variant & Params)
    {
    ShowMessage(Params.GetElement(0));
    ShowMessage(Params.GetElement(1));
    return "Hello";
    }
    //

Leave a Comment