对方法外的变量使用winmessage时出错

时间:2019-01-30 09:23:58

标签: peoplesoft peoplecode

所以我在应用程序包中的类中包含此代码。如果我将winmessage放入方法中,则没问题,但是当它在外面时,它需要声明。有人知道为什么会这样吗?这是我的代码:

发生错误的部分在WinMessage(&description);

class CopyFromProg
   method CopyFromProg();
   method getProg(&acad_prog As string);
   method getDesc(&desc As string);
   property string program;
   property string description;
end-class;

method CopyFromProg
end-method;

method getProg
   /+ &acad_prog as String +/
   &program = &acad_prog;
end-method;

method getDesc
   /+ &desc as String +/
   &description = &desc;
end-method;

WinMessage(&description);

1 个答案:

答案 0 :(得分:2)

您已在班级定义中。

该定义只能包含类声明,方法定义和构造函数。

要显示您的&description,您可以在某个事件(例如FieldChange:

import TEST_APPPACK:CopyFromProg;
Local TEST_APPPACK:CopyFromProg &test;

&test = create TEST_APPPACK:CopyFromProg();
&test.description = "yeet";
WinMessage(&test.description); /* Popup string "yeet" */

您还可以更改应用程序类的定义,包括将输出描述的方法:

class CopyFromProg
   method CopyFromProg();
   method getProg(&acad_prog As string);
   method getDesc(&desc As string);
   method showDesc();
   property string program;
   property string description;
end-class;

method CopyFromProg
end-method;

method getProg
   /+ &acad_prog as String +/
   &program = &acad_prog;
end-method;

method getDesc
   /+ &desc as String +/
   &description = &desc;
end-method;

method showDesc
   /******** output &description ********/
   WinMessage(&description);
end-method;

然后,如果您可以使用此功能,

import TEST_APPPACK:CopyFromProg;
Local TEST_APPPACK:CopyFromProg&test;

&test = create TEST_APPPACK:CopyFromProg();
&test.description = "yeet";
&test.showDesc(); /* Popup string "yeet" */