开发者

Why can't I register this method with the PascalScript compiler?

开发者 https://www.devze.com 2022-12-20 01:27 出处:网络
My question is below. Here is my setup: interface uses windows, {...,} uPSComponent_Default, uPSComponent, uPSRuntime, uPSComponent_Controls;

My question is below.

Here is my setup:

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;

Why am I getting the following error when I try to compile any script.

[Error] (1:1): Unable to register function procedure NewItem(const Caption:string; const SubItems:TStringList);

I know it has to do with my attempt to import the NewItem method into the PS compiler but I don't know why it will not accept the TStringList. I know it's the TStringList because if I take out the TStringList param and just use the method with the following signature then everything works.

    procedure NewItem(const Caption:string);

I can't find any references saying that I can't pass objects back and forth between the compiler/script and my Delphi code but I'm beginning to think that there maybe a limitation in doing exactly this type of thing.

Would it make more sense to try and pass an array of strings instead of a TStringList开发者_如何学Go?


If I were to guess, I'd say it's probably because you haven't registered the TStringList class yet. Classes have to be registered with PascalScript before it can use them.

0

精彩评论

暂无评论...
验证码 换一张
取 消