CBuilder examples of AddMethod

edited 12:41PM 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 12:41PM
    //

    #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

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.