正在研究一个东西。可是全是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;