views:

131

answers:

1

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?

+2  A: 

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.

Mason Wheeler
I figured that as well, but shouldn't including the design-time component(s) automatically register the classes contained with in? I already have the TPSImport_Classes component on my form I would have thought that would be enough. What else do I have to do?
Ryan J. Mills
Oh! I'm not that smart. I figured it out. I have to add the design-time components to the PSScript components Plugin List. I was adding only my own component to the plugins list because I was using it at runtime only. It appears that you also have to add the designtime components to the plugins list as well.
Ryan J. Mills
@Ryan: Yeah, "Design time" means "compile time" in this context.
Mason Wheeler