求Delphi一句话翻译成C++builder

RogueBear 2017-01-15 04:58:20
正在研究一个东西。可是全是Delphi。 简单的还行 复杂的就不行了。求翻译。
整个流程也不知道是啥。创建事件处理方法? 还有那个callmethod 里面的变参等等。。
求翻译成c++builder能编译通过的语句






特别是 fsScript1.AddMethod('procedure DelphiFunc(s: String; i: Integer)', CallMethod);

这个'procedure 如何翻译成c++builder啊??


{ the method handler }
function TForm1.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String;
var Params: Variant): Variant;
begin
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;
If you want to add several methods, you can do it using one method handler:

Prog.AddMethod('procedure DelphiFunc(s: String; i: Integer)', CallMethod);
Prog.AddMethod('procedure DelphiFunc2(s: String)', CallMethod);

{ the method handler }
function TForm1.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String;
var Params: Variant): Variant;
begin
{ dispatch the method call }
if MethodName = 'DELPHIFUNC' then
DelphiFunc(Params[0], Params[1])
else if MethodName = 'DELPHIFUNC2' then
DelphiFunc2(Params[0]);
end;
...全文
1225 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
这是fastscript脚本组件,它这里用的脚本是PascalScript,Delphi语法,所以翻译不成C++,但是它也支持C++Script语法,你要用CB版的fastscript。
踏岸寻柳 2017-11-22
  • 打赏
  • 举报
回复
>> fsScript1.AddMethod('procedure DelphiFunc(s: String; i: Integer)', CallMethod); 感觉这个DelphiFunc应该是函数指针签名 翻译为C++Builder语法: 1. 函数指针定义: typedef void (*DelphiFunc)(String s, int i); 2. 调用处的用法: fsScript1->AddMethod(DelphiFunc, CallMethod); 还有,这里面的CallMethod就是TForm1的这个函数: function TForm1.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; var Params: Variant): Variant;

552

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 茶馆
社区管理员
  • 茶馆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧