0

因此,我在应用程序包中的类中有此代码。如果我把 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);
4

1 回答 1

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" */
于 2019-01-31T13:27:22.890 回答