首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我不能用PascalScript编译器注册这个方法?

为什么我不能用PascalScript编译器注册这个方法?
EN

Stack Overflow用户
提问于 2010-02-09 06:16:41
回答 1查看 825关注 0票数 0

我的问题如下。

下面是我的设置:

代码语言:javascript
复制
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;

当我尝试编译任何脚本时,为什么会出现以下错误。

代码语言:javascript
复制
[Error] (1:1): Unable to register function procedure NewItem(const Caption:string; const SubItems:TStringList);

我知道这与我试图将NewItem方法导入PS编译器有关,但我不知道为什么它不接受TStringList。我知道这是TStringList,因为如果我去掉TStringList参数,只需使用带有以下签名的方法,那么一切都会正常工作。

代码语言:javascript
复制
    procedure NewItem(const Caption:string);

我找不到任何引用说我不能在编译器/脚本和我的Delphi代码之间来回传递对象,但我开始认为做这类事情可能是有限制的。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-02-09 06:42:35

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2225287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档