0

我的问题如下。

这是我的设置:

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 是否更有意义?

4

1 回答 1

2

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

于 2010-02-08T22:42:35.127 回答