이 메소드가 PascalScript 컴파일러에 등록 할 수없는 이유는 무엇입니까?

StackOverflow https://stackoverflow.com/questions/2225287

문제

내 질문은 다음과 같습니다.

내 설정은 다음과 같습니다.

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 Param을 꺼내 다음 다음 서명과 함께 메소드를 사용하면 모든 것이 작동하기 때문에 TSTRINGLIST라는 것을 알고 있습니다.

    procedure NewItem(const Caption:string);

컴파일러/스크립트와 델파이 코드 사이에서 객체를 앞뒤로 전달할 수 없다는 언급을 찾을 수는 없지만 이런 유형의 일을 정확히 수행하는 데 제한이 있다고 생각하기 시작했습니다.

tstringlist 대신 문자열 배열을 통과하는 것이 더 합리적입니까?

도움이 되었습니까?

해결책

내가 추측한다면, 나는 당신이 아직 tstringlist 클래스를 등록하지 않았기 때문일 것입니다. 클래스는 PascalScript를 사용하기 전에 등록해야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top