正在研究一個東西。可是全是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;
uj5u.com熱心網友回復:
>> 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;
uj5u.com熱心網友回復:
這是fastscript腳本組件,它這里用的腳本是PascalScript,Delphi語法,所以翻譯不成C++,但是它也支持C++Script語法,你要用CB版的fastscript。uj5u.com熱心網友回復:
參考;https://www.fast-report.com/en/product/fast-script/轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/52001.html
標籤:茶館
上一篇:DEV單步跟蹤二叉樹的創建問題
