Incompatible types

I'm evaluating FastScript 1.7 on BCB 6 and am falling at the first hurdle. I get an error compiling the following script. The fsScript1 error message is "Incompatible types: 'class String', 'String' at 1:21"
void __fastcall TForm1::Button1Click(TObject *Sender)
{
fsScript1->Clear();

fsScript1->Lines->Text = "{ ShowMsg(\"Hi there\"); }";

fsScript1->AddMethod("void ShowMsg(s:String)", CallMethod);
fsScript1->Parent = fsGlobalUnit();
fsScript1->SyntaxType = "C++Script";
if(!fsScript1->Compile())
  ShowMessage(fsScript1->ErrorMsg + " at " + fsScript1->ErrorPos);
else
  fsScript1->Execute();
}
One peculiarity: If I click Button1 a second time it all works fine!

Any help gratefully received

--
Antony

Comments

  • Have solved the problem by placing the assignment of SyntaxType above the Script specification as follows:
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    fsScript1->Clear();
    fsScript1->Parent = fsGlobalUnit();
    fsScript1->SyntaxType = "C++Script";
    
    fsScript1->Lines->Text = "{ ShowMsg(\"Hi there\"); }";
    fsScript1->AddMethod("void ShowMsg(s:String)", CallMethod);
    
    if(!fsScript1->Compile())
      ShowMessage(fsScript1->ErrorMsg + " at " + fsScript1->ErrorPos);
    else
      fsScript1->Execute();
    }
    

Leave a Comment