Access a variable inside of the script

edited 4:31AM in FastScript
Why when I try to access a variable inside of the script, I give a mistake saying that the variable already exists?

This example is very simple.
I only want to write a text and the script will show it.
Below is my example:


My error: ;)

"Identified redeclared: sText"

=======================================

My script code:

var
sText: String;
begin
ShowMessage(sText);
end.

=======================================

My Delphi code:

procedure TForm1.Button1Click(Sender: TObject);
begin
Script.Clear;
Script.Variables:=Edit1.Text;

Script.Parent := fsGlobalUnit;

if Script.Compile then
Script.Execute
else
ShowMessage(Script.ErrorMsg);
end;

Comments

  • edited 4:31AM
    Correct is:
    Script.Clear;
    Script.Lines.Assign(Memo1.Lines);
    
    Script.Parent := fsGlobalUnit;
    
    if Script.Compile then
    begin
      Script.Variables['sText']:='123';
      Script.Execute
    end
    else
      ShowMessage(Script.ErrorMsg);
    
  • edited 4:31AM
    Thanks my friend!! ;)

Leave a Comment