Access a variable inside of the script

edited 6:10AM 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 6:10AM
    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 6:10AM
    Thanks my friend!! ;)

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.