[翻译]Component Registration in Script System 在脚本系统中注册组件

Component Registration in Script System 在脚本系统中注册组件

 

To refer to our component from a script, the class, its properties and methods must first be registered in the script system. You may place the registration code in a file with the same name as the component code file, with an added 'RTTI' suffix (frxBitBtnRTTI.pas in our case). See more about classes, registration, methods and properties in the FastScript script library documentation.

要从脚本中引用我们的自己写的组件,该组件的类,属性和方法必须先注册在脚本系统中。你可以把注册代码放在相同名称的文件中作为组件的代码文件,添加的RTTI的后缀(frxbitbtnrtti.pas在我们这个例子中)。更多关于类,注册,方法和属性,请查看FastScript 脚本库文档。

 

uses fs_iinterpreter, frxBitBtn, frxClassRTTI;

type

TFunctions = class(TfsRTTIModule)

public

constructor Create(AScript: TfsScript); override;

end;

constructor TFunctions.Create(AScript: TfsScript);

begin

inherited Create(AScript);

with AScript do

begin

{ register class and then define its parent }

AddClass(TfrxBitBtnControl, 'TfrxDialogControl');

{ if there are several common controls in your unit,they can be registered here;

for example, AddClass(TfrxAnotherControl, 'TfrxDialogControl'); }

end;

end;

initialization

fsRTTIModules.Add(TFunctions);

finalization
  fsRTTIModules.Remove(TFunctions);

end.

 

可以参考 fs_imenusrtti.pas 单元

posted @ 2016-05-26 13:56  翼想天开的男孩  阅读(248)  评论(0编辑  收藏  举报