Accessing to variable

edited May 2015 in FastScript
Hi to all, I'm creating a my own debugger using Delphi XE7 and Fast Script 1.9 and I need to be able to access the variables declared within procedures
in the script.

Below the example

unit Unit1;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.fs_synmemo,
FMX.fs_iinirtti, FMX.fs_imenusrtti, FMX.fs_idialogsrtti, FMX.fs_iextctrlsrtti,
FMX.fs_iformsrtti, FMX.fs_igraphicsrtti, FMX.fs_iclassesrtti,
FMX.fs_iinterpreter, FMX.StdCtrls, FMX.Layouts, FMX.Memo, FMX.fs_ipascal,
FMX.Edit, FMX.ComboEdit, FMX.Controls.Presentation;

type
TmyMath = class(TObject)
constructor create;
function oper1(x,y:Integer):integer;
procedure oper2(x,y:Integer);
public
xx,yy:integer;
end;
TForm1 = class(TForm)
fsScript1: TfsScript;
fsClassesRTTI1: TfsClassesRTTI;
fsGraphicsRTTI1: TfsGraphicsRTTI;
fsFormsRTTI1: TfsFormsRTTI;
fsExtCtrlsRTTI1: TfsExtCtrlsRTTI;
fsDialogsRTTI1: TfsDialogsRTTI;
fsMenusRTTI1: TfsMenusRTTI;
fsIniRTTI1: TfsIniRTTI;
fsSyntaxMemo1: TfsSyntaxMemo;
Layout1: TLayout;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Layout2: TLayout;
Button4: TButton;
Memo1: TMemo;
fsPascal1: TfsPascal;
GetVars: TGroupBox;
ComboEdit1: TComboEdit;
Edit1: TEdit;
Button5: TButton;
Button7: TButton;
Label1: TLabel;
Button6: TButton;
procedure Button4Click(Sender: TObject);
procedure fsSyntaxMemo1KeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
procedure Button5Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
ApplicationInTerminate:Boolean;
Function GetProp(Instance: TObject; ClassType: TClass; const PropName: String): Variant;
procedure SetProp(Instance: TObject; ClassType: TClass; const PropName: String; Value: Variant);
Function CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; var Params: Variant): Variant;
end;

var
Form1: TForm1;

implementation

{$R *.fmx}

//TmyMath
constructor TmyMath.create;
Begin
xx:=0;
yy:=0;
End;

function TmyMath.oper1(x,y:Integer):integer;
begin
result:=x+y+xx+yy;
end;

procedure TmyMath.oper2(x,y:Integer);
begin
XX:=XX+2; YY:=YY+2;
end;

//Script functions and CallMethod
Function TForm1.GetProp(Instance: TObject; ClassType: TClass; const PropName: String): Variant;
Var PropertyName:String;
begin
Result := 0;
PropertyName:=LowerCase(PropName);
if (ClassType=TmyMath) and (PropertyName='xx') then
Result := TmyMath(Instance).xx
else if (ClassType=TmyMath) and (PropertyName='yy') then
Result := TmyMath(Instance).yy
end;

procedure TForm1.SetProp(Instance: TObject; ClassType: TClass; const PropName: String; Value: Variant);
Var PropertyName:String;
begin
PropertyName:=LowerCase(PropName);
if (ClassType=TmyMath) and (PropertyName='xx') then
TmyMath(Instance).xx:=Value
else if (ClassType=TmyMath) and (PropertyName='yy') then
TmyMath(Instance).yy:=Value;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
Try
Edit1.Text:=fsScript1.Variables[ComboEdit1.Text];
except
End;
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
ApplicationInTerminate:=True;
Close;
end;

Function TForm1.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; var Params: Variant): Variant;
Var lowMethodName:String;
begin
Result:=0;
lowMethodname:=lowerCase(MethodName);
if ClassType=TmyMath then
Begin
if lowMethodName='oper1' then result:=TmyMath(Instance).oper1(Params[0],Params[1])
else if lowMethodName='oper2' then TmyMath(Instance).oper2(Params[0],Params[1])
End;
if lowMethodName='applicationclosed' then Result:=Application.Terminated or ApplicationInTerminate;
End;

procedure TForm1.FormCreate(Sender: TObject);
begin
ApplicationInTerminate:=False;
end;

procedure TForm1.fsSyntaxMemo1KeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
begin
fsSyntaxMemo1.Repaint
end;

//
procedure TForm1.Button4Click(Sender: TObject);
Var S:String; Y:Integer;
begin
if Button4.Text='STOP' then
Begin
fsScript1.Terminate;
Button4.Text:='RUN';
fsSyntaxMemo1.ReadOnly:=True;
Memo1.Lines.Add('Stopped.');
Exit;
End;
fsScript1.Clear;
fsScript1.ClearRTTI;
fsScript1.AddRTTI;
fsScript1.AddClass(TForm, 'TForm');
fsScript1.AddClass(TApplication, 'TApplication');
fsScript1.AddObject('Self',Self);
fsScript1.AddObject('Application',Application);
fsScript1.AddObject('Form1', Form1);
fsScript1.AddClass(TPosition,'TPersistent');
with fsScript1.AddClass(TmyMath,'TObject') do
Begin
AddMethod('function oper1(x,y:Integer):integer', CallMethod);
AddMethod('procedure oper2(x,y:Integer)', CallMethod);
AddProperty('xx', 'integer', GetProp, SetProp);
AddProperty('yy', 'integer', GetProp, SetProp);
End;
fsScript1.AddObject('Button1', Button1);
fsScript1.AddObject('Button2', Button2);
fsScript1.AddObject('Button3', Button3);
fsScript1.AddObject('Button6', Button6);
fsScript1.AddObject('Label1', Label1);
fsScript1.AddMethod('function ApplicationClosed:Boolean;', CallMethod);
fsScript1.Lines.Text:=fsSyntaxMemo1.Lines.Text;
Memo1.Lines.Clear;
if fsScript1.Compile then
Begin
fsSyntaxMemo1.ReadOnly:=True;
fsScript1.Execute;
Button4.Text:='STOP';
Memo1.Lines.Add('Compile OK - running ...');
End
else
Begin
Button4.Text:='RUN';
fsSyntaxMemo1.ReadOnly:=False;
Memo1.Lines.Add(fsScript1.ErrorPos+' : '+fsScript1.ErrorMsg);
Y:=StrToInt(Copy(fsScript1.ErrorPos,1,Pos(':',fsScript1.ErrorPos)-1))-1;
fsSyntaxMemo1.BeginUpdate;
fsSyntaxMemo1.SetPos(1,Y);
fsSyntaxMemo1.Repaint;
fsSyntaxMemo1.EndUpdate;
fsScript1.Terminate;
End;
end;

end.




object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 667
ClientWidth = 640
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
OnCreate = FormCreate
DesignerMasterStyle = 0
object fsSyntaxMemo1: TfsSyntaxMemo
Align = Client
ShowHint = True
TabOrder = 16
Cursor = crIBeam
BlockColor = claBlue
BlockFontColor = claWhite
CommentAttr.Fill.Color = claGreen
CommentAttr.Font.Family = 'Courier New'
CommentAttr.Font.Size = 14.000000000000000000
CommentAttr.Font.Style = [fsItalic]
KeywordAttr.Fill.Color = claNavy
KeywordAttr.Font.Family = 'Courier New'
KeywordAttr.Font.Size = 14.000000000000000000
KeywordAttr.Font.Style = [fsBold]
StringAttr.Fill.Color = claNavy
StringAttr.Font.Family = 'Courier New'
StringAttr.Font.Size = 14.000000000000000000
TextAttr.Font.Family = 'Courier New'
TextAttr.Font.Size = 14.000000000000000000
Border.Width = 1
FontSettings.Font.Family = 'Courier New'
FontSettings.Font.Size = 14.000000000000000000
GutterFill.Color = xFFEEC7C7
Lines.Strings = (
'Program Prova;'
'var I:Integer;'
' S:String;'
' my:TmyMath;'
''
'procedure Button2Click(Sender: TObject);'
'begin'
' Button1.Position.X:=Button1.Position.X-1;'
'end;'
''
'procedure Button3Click(Sender: TObject);'
'begin'
' Button1.Position.X:=Button1.Position.X+1;'
'end;'
''
'procedure Button6Click(Sender: TObject);'
'Var X,Y:Integer;'
'begin'
' X:=0;'
' Y:=0;'
' While ApplicationClosed=False do'
' Begin'
' if X mod 100=0 then'
' Application.ProcessMessages;'
' I:=I+1;'
' Y:=Y+my.oper1(1,2);'
' Label1.Text:=IntToStr(I)+'#39' - '#39'+IntToStr(Y);'
' End;'
'end;'
''
'Begin'
' S:='#39'Init...'#39';'
' my:=TmyMath.Create;'
' my.oper1(1,2);'
' my.oper2(3,3);'
' I:=my.xx;'
' my.xx:=my.xx*3;'
' I:=my.xx;'
' Button1.Text:='#39'Prova'#39';'
' Button2.OnClick:=@Button2Click;'
' Button3.OnClick:=@Button3Click;'
' Button6.OnClick:=@Button6Click;'
'End.')
ReadOnly = False
SyntaxType = stPascal
ShowFooter = True
ShowGutter = True
OnKeyDown = fsSyntaxMemo1KeyDown
end
object Layout1: TLayout
Align = Top
Size.Width = 640.000000000000000000
Size.Height = 65.000000000000000000
Size.PlatformDefault = False
TabOrder = 17
object Button1: TButton
Position.X = 8.000000000000000000
Position.Y = 8.000000000000000000
TabOrder = 0
Text = 'Button1'
end
object Button2: TButton
Position.X = 8.000000000000000000
Position.Y = 32.000000000000000000
Size.Width = 33.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
TabOrder = 1
Text = '<'
end
object Button3: TButton
Position.X = 56.000000000000000000
Position.Y = 32.000000000000000000
Size.Width = 33.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
TabOrder = 2
Text = '>'
end
object Button7: TButton
Position.X = 573.000000000000000000
Position.Y = 3.000000000000000000
Size.Width = 64.000000000000000000
Size.Height = 30.000000000000000000
Size.PlatformDefault = False
TabOrder = 3
Text = 'Close'
OnClick = Button7Click
end
object Label1: TLabel
Position.X = 189.000000000000000000
Position.Y = 11.000000000000000000
Text = 'Label1'
end
end
object Layout2: TLayout
Align = Bottom
Position.Y = 504.000000000000000000
Size.Width = 640.000000000000000000
Size.Height = 163.000000000000000000
Size.PlatformDefault = False
TabOrder = 18
object Button4: TButton
Position.X = 8.000000000000000000
Position.Y = 8.000000000000000000
TabOrder = 0
Text = 'RUN'
OnClick = Button4Click
end
object Memo1: TMemo
Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
Position.X = 9.000000000000000000
Position.Y = 36.000000000000000000
Size.Width = 328.000000000000000000
Size.Height = 125.000000000000000000
Size.PlatformDefault = False
TabOrder = 1
end
object GetVars: TGroupBox
Position.X = 343.000000000000000000
Position.Y = 8.000000000000000000
Size.Width = 265.000000000000000000
Size.Height = 73.000000000000000000
Size.PlatformDefault = False
Text = 'GetVars'
TabOrder = 2
object ComboEdit1: TComboEdit
Touch.InteractiveGestures = [LongTap, DoubleTap]
TabOrder = 1
ItemHeight = 19.000000000000000000
Items.Strings = (
'I'
'S'
'my'
'my.xx'
'X'
'Button6Click.X'
'Y')
ItemIndex = 0
Text = 'I'
Position.X = 64.000000000000000000
Position.Y = 18.000000000000000000
Size.Width = 193.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
end
object Edit1: TEdit
Touch.InteractiveGestures = [LongTap, DoubleTap]
TabOrder = 2
Position.X = 64.000000000000000000
Position.Y = 44.000000000000000000
Size.Width = 193.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
end
object Button5: TButton
Position.X = 8.000000000000000000
Position.Y = 18.000000000000000000
Size.Width = 49.000000000000000000
Size.Height = 48.000000000000000000
Size.PlatformDefault = False
TabOrder = 3
Text = 'Get?'
OnClick = Button5Click
end
end
object Button6: TButton
Position.X = 104.000000000000000000
Position.Y = 8.000000000000000000
TabOrder = 3
Text = 'Loop'
end
end
object fsScript1: TfsScript
SyntaxType = 'PascalScript'
Left = 536
Top = 16
end
object fsClassesRTTI1: TfsClassesRTTI
Left = 304
Top = 216
end
object fsGraphicsRTTI1: TfsGraphicsRTTI
Left = 312
Top = 224
end
object fsFormsRTTI1: TfsFormsRTTI
Left = 320
Top = 232
end
object fsExtCtrlsRTTI1: TfsExtCtrlsRTTI
Left = 328
Top = 240
end
object fsDialogsRTTI1: TfsDialogsRTTI
Left = 336
Top = 248
end
object fsMenusRTTI1: TfsMenusRTTI
Left = 344
Top = 256
end
object fsIniRTTI1: TfsIniRTTI
Left = 352
Top = 264
end
object fsPascal1: TfsPascal
Left = 448
Top = 89
end
end


If I wish to access (i.e. to variable 'X') declared inside the script the compiler return Variable Unkown.

Could you please help me?

Comments

  • edited 9:18AM
    Hi to all, I'm creating a my own debugger using Delphi XE7 and Fast Script 1.9 and I need to be able to access the variables declared within procedures
    in the script.

    Below the example

    unit Unit1;

    interface

    uses
    System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
    FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.fs_synmemo,
    FMX.fs_iinirtti, FMX.fs_imenusrtti, FMX.fs_idialogsrtti, FMX.fs_iextctrlsrtti,
    FMX.fs_iformsrtti, FMX.fs_igraphicsrtti, FMX.fs_iclassesrtti,
    FMX.fs_iinterpreter, FMX.StdCtrls, FMX.Layouts, FMX.Memo, FMX.fs_ipascal,
    FMX.Edit, FMX.ComboEdit, FMX.Controls.Presentation;

    type
    TmyMath = class(TObject)
    constructor create;
    function oper1(x,y:Integer):integer;
    procedure oper2(x,y:Integer);
    public
    xx,yy:integer;
    end;
    TForm1 = class(TForm)
    fsScript1: TfsScript;
    fsClassesRTTI1: TfsClassesRTTI;
    fsGraphicsRTTI1: TfsGraphicsRTTI;
    fsFormsRTTI1: TfsFormsRTTI;
    fsExtCtrlsRTTI1: TfsExtCtrlsRTTI;
    fsDialogsRTTI1: TfsDialogsRTTI;
    fsMenusRTTI1: TfsMenusRTTI;
    fsIniRTTI1: TfsIniRTTI;
    fsSyntaxMemo1: TfsSyntaxMemo;
    Layout1: TLayout;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Layout2: TLayout;
    Button4: TButton;
    Memo1: TMemo;
    fsPascal1: TfsPascal;
    GetVars: TGroupBox;
    ComboEdit1: TComboEdit;
    Edit1: TEdit;
    Button5: TButton;
    Button7: TButton;
    Label1: TLabel;
    Button6: TButton;
    procedure Button4Click(Sender: TObject);
    procedure fsSyntaxMemo1KeyDown(Sender: TObject; var Key: Word;
    var KeyChar: Char; Shift: TShiftState);
    procedure Button5Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    ApplicationInTerminate:Boolean;
    Function GetProp(Instance: TObject; ClassType: TClass; const PropName: String): Variant;
    procedure SetProp(Instance: TObject; ClassType: TClass; const PropName: String; Value: Variant);
    Function CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; var Params: Variant): Variant;
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.fmx}

    //TmyMath
    constructor TmyMath.create;
    Begin
    xx:=0;
    yy:=0;
    End;

    function TmyMath.oper1(x,y:Integer):integer;
    begin
    result:=x+y+xx+yy;
    end;

    procedure TmyMath.oper2(x,y:Integer);
    begin
    XX:=XX+2; YY:=YY+2;
    end;

    //Script functions and CallMethod
    Function TForm1.GetProp(Instance: TObject; ClassType: TClass; const PropName: String): Variant;
    Var PropertyName:String;
    begin
    Result := 0;
    PropertyName:=LowerCase(PropName);
    if (ClassType=TmyMath) and (PropertyName='xx') then
    Result := TmyMath(Instance).xx
    else if (ClassType=TmyMath) and (PropertyName='yy') then
    Result := TmyMath(Instance).yy
    end;

    procedure TForm1.SetProp(Instance: TObject; ClassType: TClass; const PropName: String; Value: Variant);
    Var PropertyName:String;
    begin
    PropertyName:=LowerCase(PropName);
    if (ClassType=TmyMath) and (PropertyName='xx') then
    TmyMath(Instance).xx:=Value
    else if (ClassType=TmyMath) and (PropertyName='yy') then
    TmyMath(Instance).yy:=Value;
    end;

    procedure TForm1.Button5Click(Sender: TObject);
    begin
    Try
    Edit1.Text:=fsScript1.Variables[ComboEdit1.Text];
    except
    End;
    end;

    procedure TForm1.Button7Click(Sender: TObject);
    begin
    ApplicationInTerminate:=True;
    Close;
    end;

    Function TForm1.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; var Params: Variant): Variant;
    Var lowMethodName:String;
    begin
    Result:=0;
    lowMethodname:=lowerCase(MethodName);
    if ClassType=TmyMath then
    Begin
    if lowMethodName='oper1' then result:=TmyMath(Instance).oper1(Params[0],Params[1])
    else if lowMethodName='oper2' then TmyMath(Instance).oper2(Params[0],Params[1])
    End;
    if lowMethodName='applicationclosed' then Result:=Application.Terminated or ApplicationInTerminate;
    End;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    ApplicationInTerminate:=False;
    end;

    procedure TForm1.fsSyntaxMemo1KeyDown(Sender: TObject; var Key: Word;
    var KeyChar: Char; Shift: TShiftState);
    begin
    fsSyntaxMemo1.Repaint
    end;

    //
    procedure TForm1.Button4Click(Sender: TObject);
    Var S:String; Y:Integer;
    begin
    if Button4.Text='STOP' then
    Begin
    fsScript1.Terminate;
    Button4.Text:='RUN';
    fsSyntaxMemo1.ReadOnly:=True;
    Memo1.Lines.Add('Stopped.');
    Exit;
    End;
    fsScript1.Clear;
    fsScript1.ClearRTTI;
    fsScript1.AddRTTI;
    fsScript1.AddClass(TForm, 'TForm');
    fsScript1.AddClass(TApplication, 'TApplication');
    fsScript1.AddObject('Self',Self);
    fsScript1.AddObject('Application',Application);
    fsScript1.AddObject('Form1', Form1);
    fsScript1.AddClass(TPosition,'TPersistent');
    with fsScript1.AddClass(TmyMath,'TObject') do
    Begin
    AddMethod('function oper1(x,y:Integer):integer', CallMethod);
    AddMethod('procedure oper2(x,y:Integer)', CallMethod);
    AddProperty('xx', 'integer', GetProp, SetProp);
    AddProperty('yy', 'integer', GetProp, SetProp);
    End;
    fsScript1.AddObject('Button1', Button1);
    fsScript1.AddObject('Button2', Button2);
    fsScript1.AddObject('Button3', Button3);
    fsScript1.AddObject('Button6', Button6);
    fsScript1.AddObject('Label1', Label1);
    fsScript1.AddMethod('function ApplicationClosed:Boolean;', CallMethod);
    fsScript1.Lines.Text:=fsSyntaxMemo1.Lines.Text;
    Memo1.Lines.Clear;
    if fsScript1.Compile then
    Begin
    fsSyntaxMemo1.ReadOnly:=True;
    fsScript1.Execute;
    Button4.Text:='STOP';
    Memo1.Lines.Add('Compile OK - running ...');
    End
    else
    Begin
    Button4.Text:='RUN';
    fsSyntaxMemo1.ReadOnly:=False;
    Memo1.Lines.Add(fsScript1.ErrorPos+' : '+fsScript1.ErrorMsg);
    Y:=StrToInt(Copy(fsScript1.ErrorPos,1,Pos(':',fsScript1.ErrorPos)-1))-1;
    fsSyntaxMemo1.BeginUpdate;
    fsSyntaxMemo1.SetPos(1,Y);
    fsSyntaxMemo1.Repaint;
    fsSyntaxMemo1.EndUpdate;
    fsScript1.Terminate;
    End;
    end;

    end.




    object Form1: TForm1
    Left = 0
    Top = 0
    Caption = 'Form1'
    ClientHeight = 667
    ClientWidth = 640
    FormFactor.Width = 320
    FormFactor.Height = 480
    FormFactor.Devices = [Desktop]
    OnCreate = FormCreate
    DesignerMasterStyle = 0
    object fsSyntaxMemo1: TfsSyntaxMemo
    Align = Client
    ShowHint = True
    TabOrder = 16
    Cursor = crIBeam
    BlockColor = claBlue
    BlockFontColor = claWhite
    CommentAttr.Fill.Color = claGreen
    CommentAttr.Font.Family = 'Courier New'
    CommentAttr.Font.Size = 14.000000000000000000
    CommentAttr.Font.Style = [fsItalic]
    KeywordAttr.Fill.Color = claNavy
    KeywordAttr.Font.Family = 'Courier New'
    KeywordAttr.Font.Size = 14.000000000000000000
    KeywordAttr.Font.Style = [fsBold]
    StringAttr.Fill.Color = claNavy
    StringAttr.Font.Family = 'Courier New'
    StringAttr.Font.Size = 14.000000000000000000
    TextAttr.Font.Family = 'Courier New'
    TextAttr.Font.Size = 14.000000000000000000
    Border.Width = 1
    FontSettings.Font.Family = 'Courier New'
    FontSettings.Font.Size = 14.000000000000000000
    GutterFill.Color = xFFEEC7C7
    Lines.Strings = (
    'Program Prova;'
    'var I:Integer;'
    ' S:String;'
    ' my:TmyMath;'
    ''
    'procedure Button2Click(Sender: TObject);'
    'begin'
    ' Button1.Position.X:=Button1.Position.X-1;'
    'end;'
    ''
    'procedure Button3Click(Sender: TObject);'
    'begin'
    ' Button1.Position.X:=Button1.Position.X+1;'
    'end;'
    ''
    'procedure Button6Click(Sender: TObject);'
    'Var X,Y:Integer;'
    'begin'
    ' X:=0;'
    ' Y:=0;'
    ' While ApplicationClosed=False do'
    ' Begin'
    ' if X mod 100=0 then'
    ' Application.ProcessMessages;'
    ' I:=I+1;'
    ' Y:=Y+my.oper1(1,2);'
    ' Label1.Text:=IntToStr(I)+'#39' - '#39'+IntToStr(Y);'
    ' End;'
    'end;'
    ''
    'Begin'
    ' S:='#39'Init...'#39';'
    ' my:=TmyMath.Create;'
    ' my.oper1(1,2);'
    ' my.oper2(3,3);'
    ' I:=my.xx;'
    ' my.xx:=my.xx*3;'
    ' I:=my.xx;'
    ' Button1.Text:='#39'Prova'#39';'
    ' Button2.OnClick:=@Button2Click;'
    ' Button3.OnClick:=@Button3Click;'
    ' Button6.OnClick:=@Button6Click;'
    'End.')
    ReadOnly = False
    SyntaxType = stPascal
    ShowFooter = True
    ShowGutter = True
    OnKeyDown = fsSyntaxMemo1KeyDown
    end
    object Layout1: TLayout
    Align = Top
    Size.Width = 640.000000000000000000
    Size.Height = 65.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 17
    object Button1: TButton
    Position.X = 8.000000000000000000
    Position.Y = 8.000000000000000000
    TabOrder = 0
    Text = 'Button1'
    end
    object Button2: TButton
    Position.X = 8.000000000000000000
    Position.Y = 32.000000000000000000
    Size.Width = 33.000000000000000000
    Size.Height = 22.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 1
    Text = '<'
    end
    object Button3: TButton
    Position.X = 56.000000000000000000
    Position.Y = 32.000000000000000000
    Size.Width = 33.000000000000000000
    Size.Height = 22.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 2
    Text = '>'
    end
    object Button7: TButton
    Position.X = 573.000000000000000000
    Position.Y = 3.000000000000000000
    Size.Width = 64.000000000000000000
    Size.Height = 30.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 3
    Text = 'Close'
    OnClick = Button7Click
    end
    object Label1: TLabel
    Position.X = 189.000000000000000000
    Position.Y = 11.000000000000000000
    Text = 'Label1'
    end
    end
    object Layout2: TLayout
    Align = Bottom
    Position.Y = 504.000000000000000000
    Size.Width = 640.000000000000000000
    Size.Height = 163.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 18
    object Button4: TButton
    Position.X = 8.000000000000000000
    Position.Y = 8.000000000000000000
    TabOrder = 0
    Text = 'RUN'
    OnClick = Button4Click
    end
    object Memo1: TMemo
    Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
    Position.X = 9.000000000000000000
    Position.Y = 36.000000000000000000
    Size.Width = 328.000000000000000000
    Size.Height = 125.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 1
    end
    object GetVars: TGroupBox
    Position.X = 343.000000000000000000
    Position.Y = 8.000000000000000000
    Size.Width = 265.000000000000000000
    Size.Height = 73.000000000000000000
    Size.PlatformDefault = False
    Text = 'GetVars'
    TabOrder = 2
    object ComboEdit1: TComboEdit
    Touch.InteractiveGestures = [LongTap, DoubleTap]
    TabOrder = 1
    ItemHeight = 19.000000000000000000
    Items.Strings = (
    'I'
    'S'
    'my'
    'my.xx'
    'X'
    'Button6Click.X'
    'Y')
    ItemIndex = 0
    Text = 'I'
    Position.X = 64.000000000000000000
    Position.Y = 18.000000000000000000
    Size.Width = 193.000000000000000000
    Size.Height = 22.000000000000000000
    Size.PlatformDefault = False
    end
    object Edit1: TEdit
    Touch.InteractiveGestures = [LongTap, DoubleTap]
    TabOrder = 2
    Position.X = 64.000000000000000000
    Position.Y = 44.000000000000000000
    Size.Width = 193.000000000000000000
    Size.Height = 22.000000000000000000
    Size.PlatformDefault = False
    end
    object Button5: TButton
    Position.X = 8.000000000000000000
    Position.Y = 18.000000000000000000
    Size.Width = 49.000000000000000000
    Size.Height = 48.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 3
    Text = 'Get?'
    OnClick = Button5Click
    end
    end
    object Button6: TButton
    Position.X = 104.000000000000000000
    Position.Y = 8.000000000000000000
    TabOrder = 3
    Text = 'Loop'
    end
    end
    object fsScript1: TfsScript
    SyntaxType = 'PascalScript'
    Left = 536
    Top = 16
    end
    object fsClassesRTTI1: TfsClassesRTTI
    Left = 304
    Top = 216
    end
    object fsGraphicsRTTI1: TfsGraphicsRTTI
    Left = 312
    Top = 224
    end
    object fsFormsRTTI1: TfsFormsRTTI
    Left = 320
    Top = 232
    end
    object fsExtCtrlsRTTI1: TfsExtCtrlsRTTI
    Left = 328
    Top = 240
    end
    object fsDialogsRTTI1: TfsDialogsRTTI
    Left = 336
    Top = 248
    end
    object fsMenusRTTI1: TfsMenusRTTI
    Left = 344
    Top = 256
    end
    object fsIniRTTI1: TfsIniRTTI
    Left = 352
    Top = 264
    end
    object fsPascal1: TfsPascal
    Left = 448
    Top = 89
    end
    end


    If I wish to access (i.e. to variable 'X') declared inside the script the compiler return Variable Unkown.

    Could you please help me?

    Are there any able to help me on this matter?

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.