我正在为Delphi寻找一个很好的免费脚本引擎.我想添加脚本到应用程序,以便我可以编写小测试脚本.具体我需要:
>类似帕斯卡的语法
> current(我看过RemObjects Pascal Scripting,但是根据我发现的一个帖子,它是“过时的”).
我不需要全面的语言支持,只是基础知识.我看到这个:Scripting library for Delphi,但我假设从那以后,事情已经有一点点了.
我想要做的就是将一个备忘录组件添加到我的程序中,并在运行时添加一个源代码到备忘录,然后点击一个按钮.我希望脚本能够访问我的应用程序的变量和函数.
实现这一目标最简单的途径是什么?示例程序如下.
program Project31; uses Forms,Unit36 in 'Unit36.pas' {Form36}; {$R *.res} begin Application.Initialize; Application.CreateForm(TForm36,Form36); Application.Run; end.
.
unit Unit36; interface uses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls; type TForm36 = class(TForm) Button1: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form36: TForm36; implementation {$R *.dfm} procedure RoutineInMyApplication ; begin ShowMessage ('Hello from my Application') ; end ; procedure TForm36.Button1Click(Sender: TObject); begin //ExecuteScript (Memo1.Lines) ; end ; end.
.
object Form36: TForm36 Left = 0 Top = 0 Caption = 'Form36' ClientHeight = 174 ClientWidth = 391 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object Button1: TButton Left = 300 Top = 72 Width = 75 Height = 25 Caption = 'Button1' TabOrder = 0 OnClick = Button1Click end object Memo1: TMemo Left = 8 Top = 21 Width = 241 Height = 145 Lines.Strings = ( 'begin' 'ShowMessage ('#39'Hello world'#39') ;' 'CallSomehow (RoutineInMyApplication) ;' 'end.' ' ') TabOrder = 1 end end
解决方法
尝试
Eric Grange目前维护的
dwscript
库.