使用innerfuse脚本

使用innerfuse脚本语言
innerfuse脚本语言(或交互式财务计划系统)是建立从不同的2个部分:
–编译器
–运行
编译器,可以发现在ifpscomp.pas单元,运行时在ifps3.pas单位,不依赖于对方。可以使用编译器和运行时直接使用组件,或它的包装,该tifps3compexec组件可以在ifps3compexec单位和包装的编译器和执行在一个易于使用的类。使用组件的版本ifps3必须把它放在窗体或数据模块。设置或指定脚本属性,调用编译方法和执行方法。任何错误警告或提示发生在编译可以发现在该compilermessages数组属性和运行时错误可以通过阅读execerrortostring属性。
以下示例将编译和执行空脚本(开始的):
var
   Messages: string;
   compiled: boolean;
 begin
   ce.Script.Text := 'begin end.';
   Compiled := Ce.Compile;
   for i := 0 to ce.CompilerMessageCount -  do
     Messages := Messages + ce.CompilerMessages[i].MessageToString + # 3# 0;
   if Compiled then
     Messages := Messages + 'Succesfully compiled'# 3# 0;
   ShowMessage('Compiled Script: '# 3# 0+Messages);
   if Compiled then
   begin
     if Ce.Execute then
          ShowMessage('Succesfully Executed')
        else
          ShowMessage('Error while executing script: '+Ce.ExecErrorToString);
   end;
 end;
默认组件不仅增加了一些标准功能的脚本引擎(确切的名单在ifpscomp.pas顶部)。除了标准功能有一些库文件包含在ifps3:
tifps3dllplugin:  允许脚本使用动态链接库函数的语法是:function FindWindo (C1, C2: PChar): Longint;external 'FindWindo  A@user32.dll stdcall';
TIFPS3CE_ Controls: 进出库controls.pas和graphics.pas。
TIFPS3CE_DB:   进出库db.pas。
TIFPS3CE_DateUtils: 进出库的日期/时间相关函数。
TIFPS3CE_Std:   进出库tobject和类单位。
TIFPS3CE_StdCtrls:  进出库extctrls和按钮。
TIFPS3CE_Forms:  导入库的形式和菜单单元。
使用这些库,将它们添加到您的窗体或数据模块,选择TIFPS3CompExec组件的插件属性旁的[……],设置插件组件的插件属性。除了标准的库文件,可以方便地添加新的功能的脚本引擎。例如,创建一个新的方法来揭露脚本引擎:
procedure TForm .ShowNewMessage(const Message: string);
 begin
   ShowMessage('ShowNewMessage invoked:'# 13#10+Message);
 end;
接下来你须要分配一个事件处理器(event handler)给OnCompile事件,并使用TIFPS3CompExec的AddMethod 方法去添加的实际方法:
procedure TForm .CECompile(Sender: TIFPS3CompExec);
 begin
   Sender.AddMethod(Self, @TForm .ShowNewMessage, 'procedure ShowNewMessage
 (const Message: string);');
 end;
一个使用这个函数的简单样本,可以看起来像这样:
begin
   ShowNewMessage('Show This !');
 end.
高级功能:
IFPS3包括预处理,允许你使用定义({$IFDEF}, {$ELSE}, {$ENDIF}),并且包含其他文件在你的脚本。({$I filename.inc}),要使用这些功能,得把UsePreprocessor属性设置为true,还必须得设置MainFileName为脚本的名字放在你的脚本属性里。这些定义属性指定默认的设置,当需要一个包含文件时要调用OnNeedFile事件。
function TForm .ceNeedFile(Sender: TObject; const OrginFileName: String;
   var FileName, Output: String): Boolean;
 var
   path: string;
   f: TFileStream;
 begin
   Path := ExtractFilePath(ParamStr(0))  + FileName;
   try
     F := TFileStream.Create(Path, fmOpenRead or fmShareDenyWrite);
   except
     Result := false;
     exit;
   end;
   try
     SetLength(Output, f.Size);
     f.Read(Output[ ], Length(Output));
   finally
     f.Free;
   end;
   Result := True;
 end;
当这些属性设置好后,CompilerMessages数组属性将包含出现在这些讯息的文件名字。
IFPS3的另一特色是可能从Delphi调用方法脚本。下面的示例将作为一个脚本:

function TestFunction(Param : Double; Data: String): Longint;
 begin
   ShowNewMessage('Param : '+FloatToString(param )+# 13# 10+'Data: '+Data);
   Result :=  1234567;
 end;
 begin
 end.
在使用这些脚本函数之前,必须检查匹配的参数和结果类型,这些可以在OnVerifyProc事件中完成。
procedure TForm .CEVerifyProc(Sender: TIFPS3CompExec;
   Proc: TIFPSInternalProcedure; const Decl: String; var Error: Boolean);
 begin
   if Proc.Name = 'TESTFUNCTION' then
   begin
     if not ExportCheck(Sender.Comp, Proc, [btU8, btDouble, btString], [pmIn,
 pmIn]) then
     begin
       Sender.Comp.MakeError('', ecCustomError, 'Function header for
 TestFunction does not match.');
       Error := True;
     end else
     begin
       Proc.aExport := etExportDecl;
       Error := False;
     end;
   end else
     Error := False;
 end;
ExportCheck测试参数匹配,在这种情况下btu8是一个布尔值(结果型),btdouble是第一个参数和btString第二个参数。[pmIn pmIn]说明这两个参数都是in参数。可以使用这个脚本函数,必须为这个函数创建一个事件声明并调用。
type
   TTestFunction = function (Param : Double; Data: String): Longint of object;
 ...
 var
   Meth: TTestFunction;
   Meth := TTestFunction(ce.GetProcMethod('TESTFUNCTION'));
   if @Meth = nil then
     raise Exception.Create('Unable to call TestFunction');
   ShowMessage('Result: '+IntToStr(Meth(pi, DateTimeToStr(Now))));
这也可以在脚本引擎中添加在脚本内使用的变量。要做到这一点,必须使用AddRegisteredVariable函数。在OnExecute事件可以这样设置:
procedure TForm .ceExecute(Sender: TIFPS3CompExec);
 begin
   CE.SetVarToInstance('SELF', Self); // For class variables
   VSetInt(CE.GetVariable('MYVAR'),  1234567);
 end;
读完这个变量,脚本执行完成后,你可以使用
OnAfterExecute事件,并用VGetInt(CE.GetVariable(“MYVAR”)。


注:
一些函数和常数,可能需要补充:ifpscomp,ifps3和ifps3utl到uses中。
——脚本引擎应用本身从来不调用Application.ProcessMessages,可能将会申请挂起,当脚本在运行时,为了避免如此,可以添加Application.ProcessMessages到TIFPS3CompExec.OnLine event。
——可能会在脚本引擎肿引用你自己的类。IFPS3 includes一个工具,在/ Unit-Importing /directory下创建导入库。
——源码部分为界面每一个method/function包含一个小的描述。这些说明,也可以/Help/Units 目录.
——一些小例子都能在/Help/下找到
—— / DUnit /目录,包含一个DUnit test application for IFPS3。你需要http://dunit.sourceforge.net/去运行这个。
——例如:如何分别使用编译器和运行时,看Demo_Import /和Demo_Kylix。
——Ide-demo和unit-import SynEdit需要http://synedit.sourceforge.net/

(以上为本人拙略翻译过来的文档,借鉴时应该谨慎)

转载于:https://www.cnblogs.com/IceKernel/archive/2011/11/30/2269426.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Pascal Script 解释器IFPS3是一个用Delphi编写的脚本引擎,它使得你能够在程序的运行中使用大多数的Object Pascal语言特性,这些程序单元可以被编译到你的应用程序中,发布时不需要其它额外的文件,它具有以下特性:1.支持变量和常量2.标准的语句控制: Begin/End, If/Then/Else, For/To/Downto/Do, Case x Of, Repeat/Until, While, uses, Exit, Continue, Break 3.函数(可以定义在脚本内部或脚本外部)4.标准的数据类型: Byte, Shortint, Char, Word, SmallInt, Cardinal, Longint, Integer, String, Real, Double, Single, Extended, Boolean, Array, Record, Enumerations 5.导入Delphi自身的函数和类,6.可以将脚本关联到Delphi对象的事件7.可以编译成一个文件然后运行Innerfuse Pascal Script 3Innerfuse Pascal Script 3 (short IFPS3) is a script engine written in Delphi. IFPS allowes you to use most of Object Pascal language within your Delphi projects at runtime. It‘s a set of units that can be compiled into your exe file so there is no need to distribute any external files. It has the following features:Variables, Constants Standard statements: Begin/End, If/Then/Else, For/To/Downto/Do, Case x Of, Repeat/Until, While, uses, Exit, Continue, Break Functions (Declared inside or outside script) Standard types: Byte, Shortint, Char, Word, SmallInt, Cardinal, Longint, Integer, String, Real, Double, Single, Extended, Boolean, Array, Record, Enumerations Importing Delphi functions and classes. Assigning script functions to Delphi events. Compiling to a file and running later Why use a script engine?A script engine allowes the end user to customize an application to his/her needs without having to recompile it, and you can update your application by just sending a script file.why use IFPS3 instead of IFPS(2)?IFPS3 compiles first and runs later, this allowes you to save the script in compiled form and run much faster than IFPS. IFPS3 also has better debugging support.downloads:http://www.carlo-kok.com/ifps3.php?mode=viewfiles
超强大、好用的Pascal语言解释器:RemObjects Pascal Script,支持以下特性: Pascal Script is a widely-used set of components for Delphi that makes it easy to add Pascal-based scripting support to your applications, so that they can extend or control your application with custom scripts. Get Pascal Script Free Now Start using Pascal Script now and download your free copy, including full source code. Pascal Script for Delphi Pascal Script is a free scripting engine that allows you to use most of the Object Pascal language within your Delphi or Free Pascal projects at runtime. Written completely in Delphi, it is composed of a set of units that can be compiled into your executable, eliminating the need to distribute any external files. Pascal Script started out as a need for a good working script, when there were none available at the time. Why use a scripting engine? A scripting engine allows an end user to customize an application to his or her needs without having to recompile it. In addition, you can update your applications by just sending a new script file that could even be compiled to byte code, which cannot easily be transformed back to source code. Pascal Script includes the following features: Variables, Constants Standard language constructs: Begin/End If/Then/Else For/To/Downto/Do Case x Of Repeat/Until While Uses Exit Continue Break Functions inside the script Calling any external DLL function (no special function headers required) Calling registered external methods All common types like Byte, Shortint, Char, Word, SmallInt, Cardinal, Longint, Integer, String, Real, Double, Single, Extended, Boolean, Array, Record, Enumerations, Variants Allows the importing and use of classes, with events, properties, methods and constructors Allows the importing and use of interface and their members Allows IDispatch dynamic method invocation through Variant Assignment of script functions to Delphi events Uses byte code as an intermediate format and allows storing and reloading compiled scripts Easy to use component version Support for include files Support for compiler defines Capability to call RemObjects SDK Services from within scripts Pascal Script includes a tool to create headers for importing classes and interfaces
在现有省、市港口信息化系统进行有效整合基础上,借鉴新 一代的感知-传输-应用技术体系,实现对码头、船舶、货物、重 大危险源、危险货物装卸过程、航管航运等管理要素的全面感知、 有效传输和按需定制服务,为行政管理人员和相关单位及人员提 供高效的管理辅助,并为公众提供便捷、实时的水运信息服务。 建立信息整合、交换和共享机制,建立健全信息化管理支撑 体系,以及相关标准规范和安全保障体系;按照“绿色循环低碳” 交通的要求,搭建高效、弹性、高可扩展性的基于虚拟技术的信 息基础设施,支撑信息平台低成本运行,实现电子政务建设和服务模式的转变。 实现以感知港口、感知船舶、感知货物为手段,以港航智能 分析、科学决策、高效服务为目的和核心理念,构建“智慧港口”的发展体系。 结合“智慧港口”相关业务工作特点及信息化现状的实际情况,本项目具体建设目标为: 一张图(即GIS 地理信息服务平台) 在建设岸线、港口、港区、码头、泊位等港口主要基础资源图层上,建设GIS 地理信息服务平台,在此基础上依次接入和叠加规划建设、经营、安全、航管等相关业务应用专题数据,并叠 加动态数据,如 AIS/GPS/移动平台数据,逐步建成航运管理处 "一张图"。系统支持扩展框架,方便未来更多应用资源的逐步整合。 现场执法监管系统 基于港口(航管)执法基地建设规划,依托统一的执法区域 管理和数字化监控平台,通过加强对辖区内的监控,结合移动平 台,形成完整的多维路径和信息追踪,真正做到问题能发现、事态能控制、突发问题能解决。 运行监测和辅助决策系统 对区域港口与航运业务日常所需填报及监测的数据经过科 学归纳及分析,采用统一平台,消除重复的填报数据,进行企业 输入和自动录入,并进行系统智能判断,避免填入错误的数据, 输入的数据经过智能组合,自动生成各业务部门所需的数据报 表,包括字段、格式,都可以根据需要进行定制,同时满足扩展 性需要,当有新的业务监测数据表需要产生时,系统将分析新的 需求,将所需字段融合进入日常监测和决策辅助平台的统一平台中,并生成新的所需业务数据监测及决策表。 综合指挥调度系统 建设以港航应急指挥中心为枢纽,以各级管理部门和经营港 口企业为节点,快速调度、信息共享的通信网络,满足应急处置中所需要的信息采集、指挥调度和过程监控等通信保障任务。 设计思路 根据项目的建设目标和“智慧港口”信息化平台的总体框架、 设计思路、建设内容及保障措施,围绕业务协同、信息共享,充 分考虑各航运(港政)管理处内部管理的需求,平台采用“全面 整合、重点补充、突出共享、逐步完善”策略,加强重点区域或 运输通道交通基础设施、运载装备、运行环境的监测监控,完善 运行协调、应急处置通信手段,促进跨区域、跨部门信息共享和业务协同。 以“统筹协调、综合监管”为目标,以提供综合、动态、实 时、准确、实用的安全畅通和应急数据共享为核心,围绕“保畅通、抓安全、促应急"等实际需求来建设智慧港口信息化平台。 系统充分整合和利用航运管理处现有相关信息资源,以地理 信息技术、网络视频技术、互联网技术、移动通信技术、云计算 技术为支撑,结合航运管理处专网与行业数据交换平台,构建航 运管理处与各部门之间智慧、畅通、安全、高效、绿色低碳的智 慧港口信息化平台。 系统充分考虑航运管理处安全法规及安全职责今后的变化 与发展趋势,应用目前主流的、成熟的应用技术,内联外引,优势互补,使系统建设具备良好的开放性、扩展性、可维护性。
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值