Demo with inputs and outputs to delphi application

edited April 2014 in FastScript
here is my code for inputs and outputs.....
When i run the script, i get an error 'incompatible types' then i run it a 2nd time, there is no error?
What is causing the incompatible types ERROR?

{Form has Edit1, Edit2, Memo1, Label4, Button
}


procedure TForm2.bRunClick(Sender: TObject);
var
a,b: integer;
begin
label4.Caption := '0';
fsScript1.Clear;
fsScript1.AddVariable('a','Integer', a);
fsScript1.AddVariable('b','Integer', [img]style_emoticons/<#EMO_DIR#>/cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" />; fsScript1.Lines := Memo1.Lines; fsScript1.Parent := fsGlobalUnit; if fsScript1.Compile then begin fsScript1.Execute; Label4.Caption := IntToStr(fsScript1.Variables); end else // execute if compilation was succesfull Label4.Caption := fsScript1.ErrorMsg; //show an error message end; function TForm2.fsScript1GetVarValue(VarName: string; VarTyp: TfsVarType; OldValue: Variant): Variant; begin if VarName='a' then Result := StrToInt(Edit1.Text) else if VarName='b' then Result := StrToInt(Edit2.Text); end; {script code in memo1 var i : integer; begin i := a + b; end. }[/img]

Comments

  • edited 7:08PM
    teddy wrote: »
    here is my code for inputs and outputs.....
    When i run the script, i get an error 'incompatible types' then i run it a 2nd time, there is no error?
    What is causing the incompatible types ERROR?

    {Form has Edit1, Edit2, Memo1, Label4, Button
    }


    procedure TForm2.bRunClick(Sender: TObject);
    var
    a,b: integer;
    begin
    label4.Caption := '0';
    fsScript1.Clear;
    fsScript1.AddVariable('a','Integer', a);
    fsScript1.AddVariable('b','Integer', [img]style_emoticons/<#EMO_DIR#>/cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" />; fsScript1.Lines := Memo1.Lines; fsScript1.Parent := fsGlobalUnit; if fsScript1.Compile then begin fsScript1.Execute; Label4.Caption := IntToStr(fsScript1.Variables); end else // execute if compilation was succesfull Label4.Caption := fsScript1.ErrorMsg; //show an error message end; function TForm2.fsScript1GetVarValue(VarName: string; VarTyp: TfsVarType; OldValue: Variant): Variant; begin if VarName='a' then Result := StrToInt(Edit1.Text) else if VarName='b' then Result := StrToInt(Edit2.Text); end; {script code in memo1 var i : integer; begin i := a + b; end. }[/img]
  • wrote:
    When i run the script, i get an error 'incompatible types' then i run it a 2nd time, there is no error?
    What is causing the incompatible types ERROR?
    I have the same problem in my test application. I use the trial version for evaluation.
    I will not order the component if this error remains.

    Thanks
    Rolf
  • I solved the problem. I read earlier posts from users encountered the same problem (what should be done before posting!!)!!

    The order of statements is important.

    This works:
      fsScript1->Clear();
      fsScript1->Parent = fsGlobalUnit(); // use standard classes and methods
      fsScript1->SyntaxType = "PascalScript";
      fsScript1->AddVariable("i", "Integer", i);
      fsScript1->Lines->Text = mCode->Lines->Text;
      if (fsScript1->Compile()) {
    	fsScript1->Execute();
      }
      else
    	ShowMessage(fsScript1->ErrorMsg);
    
    without error.

    This code:
      fsScript1->Clear();
      fsScript1->AddVariable("i", "Integer", i);
      fsScript1->Lines->Text = mCode->Lines->Text;
      fsScript1->Parent = fsGlobalUnit(); // use standard classes and methods
      fsScript1->SyntaxType = "PascalScript";
      if (fsScript1->Compile()) {
    	fsScript1->Execute();
      }
      else
    	ShowMessage(fsScript1->ErrorMsg);
    
    generated an error when the script was run the first time. Afterwards no error occurred.
  • edited 7:08PM
    re is my code for inputs and outputs.....
    When i run the script, i get an error 'incompatible types' then i run it a 2nd time, there is no error?
    What is causing the inco

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.