fastscript调用delphi方法和DELPHI调用FASTSCRIPT方法
fastscript调用Delphi过程:
1. 先创建事件处理方法:TfsCallMethodEvent
2. 然后再用调用TfsScript.AddMethod方法,第一个参数为Delphi方法的语法,第二个参数为TfsCallMethodEvent链接的一个句柄。 如在Delphi有一个过程为DelphiFunc, …..
procedure TForm1.DelphiFunc(s: String; i: Integer); begin
ShowMessage(s + ', ' + IntToStr(i)); end;
{TfsCallMethodEvent}
function TForm1.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String;
var Params: Variant): Variant; begin
if MethodName = 'DELPHIFUNC' then //注意方法名称都为大写比较。 DelphiFunc(Params[0], Params[1]); end;
procedure TForm1.Button1Click(Sender: TObject); begin
{ clear all items }
fsScript1.Clear;
{ script text }
fsScript1.Lines := Memo1.Lines;
{ frGlobalUnit contains standard types and functions }
fsScript1.Parent := fsGlobalUnit;
{ make DelphiFunc procedure visible to a script }
fsScript1.AddMethod('procedure DelphiFunc(s: String; i: Integer)', CallMethod);
{ compile the script }
if fsScript1.Compile then
fsScript1.Execute else
{ execute if compilation was succesfull }
ShowMessage(fsScript1.ErrorMsg);
{ show an error message }
end;
DELPHI调用FASTSCRIPT脚本
例如:如果在动态脚本里面有一个'ScriptFunc'的一个过程,则在delphi代码里需要写如下:
fsScript1.Clear; { script text }
fsScript1.Lines := Memo1.Lines;
{ frGlobalUnit contains standard types and functions } fsScript1.Parent := fsGlobalUnit;
{ make DelphiFunc procedure visible to a script }
{ compile the script } if fsScript1.Compile then
{ Call script function with one string parameter and one integer param } fsScript1.CallFunction('ScriptFunc', VarArrayOf(['Call ScriptFunc', 1])) else ShowMessage(fsScript1.ErrorMsg); { show an error message } end;
例如动态脚本内容如下:
procedure ScriptFunc(Msg: String; Num: Integer); begin
ShowMessage('1st param: ' + Msg + ' 2nd param: ' + IntToStr(Num)); end;
begin
DelphiFunc('Call DelphiFunc', 1); end.
fastscript调用delphi方法和DELPHI调用FASTSCRIPT方法的更多相关文章
- iOS 如果页面 A 跳转到 页面 B,A 的 viewDidDisappear 方法和 B 的 viewDidAppear 方法哪个先调用?
如果页面 A 跳转到 页面 B,A 的 viewDidDisappear 方法和 B 的 viewDidAppear 方法哪个先调用? 1. - (void)pushViewController:(U ...
- jQuery.extend()方法和jQuery.fn.extend()方法
jQuery.extend()方法和jQuery.fn.extend()方法源码分析 这两个方法用的是相同的代码,一个用于给jQuery对象或者普通对象合并属性和方法一个是针对jQuery对象的实例, ...
- Servlet的Service方法和doget 和 dopost方法的区别,常见的错误解析
package com.sxt.in; import java.io.IOException; import javax.servlet.ServletException; import javax. ...
- service 方法和doGet、doPost方法的区别
Service方法和doGet和doPost方法的区别service: 可以处理get/post方式的请求,如果servlet 中有service方法,会优先调用service方法进行处理do ...
- Ext.Ajax.request()方法和FormPanel.getForm().submit()方法,都返回success()方法的差异
我还是不发表到博客园首页吧,要不然还是要被取消,>_< 还是言归正传吧,关于Ext.Ajax.request()方法和FormPanel.getForm().submit()方法返回suc ...
- 牛客网Java刷题知识点之调用线程类的start()方法和run()方法的区别
不多说,直接上干货! 前期博客 牛客网Java刷题知识点之四种不同的方式创建线程 这里很简单 首先,系统通过调用线程类的start()方法来启动一个线程,此时这个线程处于就绪状态,而非运行状态,也就意 ...
- toString方法和valueof()方法的区别
JavaScript引用类型之Array数组的toString()和valueof()方法的区别 一.转换方法 1.在JavaScript中几乎所有对象都具有toLocaleString().to ...
- Java创建线程后,调用start()方法和run()的区别
1) start方法: 用start方法来启动线程,真正实现了多线程运行,这时无需等待run方法体代码执行完毕而直接继续执行下面的代码.通过调用Thread类的start()方法来启动一个线程,这时此 ...
- 利用游标返回结果集的的例子(Oracle 存储过程)JAVA调用方法和.NET调用方法
在sqlplus中建立如下的内容: 1.程序包 SQL> create or replace package types 2 as 3 type cursorType is re ...
随机推荐
- file类型允许的文件格式设置问题,“选择文件”打开缓慢
1,file类型的input对于打开的选择框的属性是由以下两个属性控制的: ①multiple="multiple" :一次可以选择多个文件 ②accept="image ...
- MVC项目中应用富文本编辑器UEditor中的几个坑
UEditor:百度出品 官网连接:http://ueditor.baidu.com/website/ 错误现象:在官网上复制到本地后,上传图片功能不能用, 控制台提示:“请求后台配置项http错误, ...
- jquery 连写注释;siblings() 方法;jQuery 的3种滑动方法;slideUp()向上滑动;slideDown()向下滑动;slideToggle()来回滑动
首先我们看两个连写注释 第一个: /* 点击头像,显示基本资料 */ $(".f-chatTit a.avatar").click(function(){ $(this).hi ...
- 抛出自定义异常,spring AOP事务不回滚的解决方案
spring AOP 默认对RuntimeException()异常或是其子类进行事务回滚,也就是说 事务回滚:throw new RuntimeException("xxxxxxxxxxx ...
- hihoCoder #1182 欧拉路·三 (变形)
题意: 写出一个环,环上有2^n个格子,每个格子中的数字是0或1,相连着的n个格子可以组成一个数的二进制,要求给出这2^n个数字的序列,使得组成的2^n个数字全是不同的.(即从0到2^n-1) 思路: ...
- spring security的标签库
应用标签库:<%@ taglib prefix='security ' uri='http://www.springframework.org/security /tags' %> < ...
- python练习程序(c100经典例6)
题目: 用*号输出字母C的图案. print "***" print "*" print "*" print "***"
- dede调用第一张大图,非缩略图
1.找到include/extend.func.php加入现在函数 function firstimg($str_pic) { $str_sub=substr($str_pic,0,-7)." ...
- 深入学习Heritrix---解析处理器(Processor)(转)
深入学习Heritrix---解析处理器(Processor) 本节解析与处理器有关的内容. 与处理器有关的主要在以下几个类:Processor(处理器类),ProcessorChain(处理器类), ...
- python 对数函数
from math import logfrom math import e print e #自然对数print log(e) #log函数默认是以e为底print log(100,10) #以10 ...