Delphi 为什么可以';我是否向PascalScript编译器注册此方法?

Delphi 为什么可以';我是否向PascalScript编译器注册此方法?,delphi,delphi-2009,pascalscript,Delphi,Delphi 2009,Pascalscript,我的问题如下 以下是我的设置: interface uses windows, {...,} uPSComponent_Default, uPSComponent, uPSRuntime, uPSComponent_Controls; TForm1 = class(TForm) //... PSScript1: TPSScript; PSImport_Classes1: TPSImport_Classes; PSImport_Controls1: T

我的问题如下

以下是我的设置:

interface 

  uses windows, {...,} uPSComponent_Default, uPSComponent, uPSRuntime, uPSComponent_Controls;

  TForm1 = class(TForm)
    //...
    PSScript1: TPSScript;
    PSImport_Classes1: TPSImport_Classes;
    PSImport_Controls1: TPSImport_Controls;
    procedure PSScript1Compile(Sender: TPSScript);
    //...
  Private
    procedure NewItem(const Caption:string; const SubItems:TStringList);
    //...
  end;

implementation

  {...}

  procedure TForm1.PSScript1Compile(Sender: TPSScript);
  begin
    //...
    Sender.AddMethod(Self, @TForm1.NewItem,  'procedure NewItem(const Caption:string; const SubItems:TStringList);');
    //...
  end;
为什么我在编译任何脚本时会出现以下错误

[Error] (1:1): Unable to register function procedure NewItem(const Caption:string; const SubItems:TStringList);
我知道这与我试图将NewItem方法导入PS编译器有关,但我不知道为什么它不接受TStringList。我知道这是TStringList,因为如果我取出TStringList参数,只使用带有以下签名的方法,那么一切都会工作

    procedure NewItem(const Caption:string);
我找不到任何说明我不能在编译器/脚本和我的Delphi代码之间来回传递对象的引用,但我开始认为,完全执行这种类型的操作可能有局限性


尝试传递字符串数组而不是TStringList是否更有意义?

如果我猜的话,可能是因为您还没有注册TStringList类。类必须先在PascalScript中注册,然后才能使用它们。

我也这么认为,但不应该包括设计时组件,自动将中包含的类注册到中?我的表单上已经有了TPSImport_类组件,我认为这就足够了。我还能做什么?哦!我没那么聪明。我想出来了。我必须将设计时组件添加到PSScript组件插件列表中。我只是将自己的组件添加到插件列表中,因为我只在运行时使用它。看起来您还必须将设计时组件添加到插件列表中。@Ryan:是的,在这个上下文中,“设计时”的意思是“编译时”。