procedure TForm1.registerSelf(AParst: TPaxCompiler); //注册
var iCount: Integer;
Aindex: Integer;
AObject: TComponent;begin for iCount := 0 to self.ComponentCount - 1 do
begin
AObject := Components[iCount];
Aindex := AParst.RegisterClassType(0, AObject.ClassType) ;
AParst.RegisterVariable(0, AObject.Name, Aindex, @AObject);
end;
end;
end;
Aindex := AParst.RegisterClassType(0, self.ClassType);
AParst.RegisterVariable(0, 'Self', Aindex, @self);
end;这样注册,运行脚本的时候就会报错
后来改成这样procedure TForm1.registerSelf(AParst: TPaxCompiler); //注册
var iCount: Integer;
Aindex: Integer;
AObject: TComponent;begin for iCount := 0 to self.ComponentCount - 1 do
begin
AObject := Components[iCount];
if AObject is TButton then
begin
Aindex := AParst.RegisterClassType(0, TButton) ;
AParst.RegisterVariable(0, AObject.Name, Aindex, @AObject);
end;
end;
end;
end;
Aindex := AParst.RegisterClassType(0, self.ClassType);
AParst.RegisterVariable(0, 'Self', Aindex, @self);
end;运行也报错如果用 Aindex := AParst.RegisterClassType(0, TButton) ;
AParst.RegisterVariable(0, 'Button1', Aindex, @Button1);
AParst.RegisterVariable(0, 'Button2', Aindex, @Button2);
Aindex := AParst.RegisterClassType(0, self.ClassType);
AParst.RegisterVariable(0, 'Self', Aindex, @self);
这样不会报错,请教一下,怎么循环注册这些组件,并且运行不报错
----------------------------------------------
var iCount: Integer;
Aindex: Integer;
AObject: TComponent;begin for iCount := 0 to self.ComponentCount - 1 do
begin
AObject := Components[iCount];
Aindex := AParst.RegisterClassType(0, AObject.ClassType) ;
AParst.RegisterVariable(0, AObject.Name, Aindex, @AObject);
end;
end;
end;
Aindex := AParst.RegisterClassType(0, self.ClassType);
AParst.RegisterVariable(0, 'Self', Aindex, @self);
end;这样注册,运行脚本的时候就会报错
后来改成这样procedure TForm1.registerSelf(AParst: TPaxCompiler); //注册
var iCount: Integer;
Aindex: Integer;
AObject: TComponent;begin for iCount := 0 to self.ComponentCount - 1 do
begin
AObject := Components[iCount];
if AObject is TButton then
begin
Aindex := AParst.RegisterClassType(0, TButton) ;
AParst.RegisterVariable(0, AObject.Name, Aindex, @AObject);
end;
end;
end;
end;
Aindex := AParst.RegisterClassType(0, self.ClassType);
AParst.RegisterVariable(0, 'Self', Aindex, @self);
end;运行也报错如果用 Aindex := AParst.RegisterClassType(0, TButton) ;
AParst.RegisterVariable(0, 'Button1', Aindex, @Button1);
AParst.RegisterVariable(0, 'Button2', Aindex, @Button2);
Aindex := AParst.RegisterClassType(0, self.ClassType);
AParst.RegisterVariable(0, 'Self', Aindex, @self);
这样不会报错,请教一下,怎么循环注册这些组件,并且运行不报错
----------------------------------------------
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货