0

So I have this code in my Class inside an Application Package. If i put the winmessage inside the method it has no problem, but when its outside it says it needs a statement. Any one knows why this is happening? Here is my code:

The part the error occurs is in 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);
Link
  • 171
  • 2
  • 19
  • I don't know. But I do know `WinMessage()` is deprecated in favor of `MessageBox()` (but be aware they can behave as [think-time](https://docs.oracle.com/cd/E24150_01/pt851h2/eng/psbooks/tpcd/chapter.htm?File=tpcd/htm/tpcd09.htm) functions depending on how you call them). Some other alternatives if you don't actually need a dialog box to pop up in front of an end user are `WriteToLog()` or `Warning()`. – qyb2zm302 Jan 31 '19 at 00:21
  • Your getProg and getDesc methods should probably be named setProg and setDesc, because that is what they do. – Based Jan 31 '19 at 13:56

1 Answers1

2

You are in your class definition.

The definition can only include the class declaration, method definitions and constructors.

To show your &description you can do the following, on an event, e.g. FieldChange:

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

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

You can also alter your application class definition, including a method that will output description:

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;

Then in an event you would be able to use:

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

&test = create TEST_APPPACK:CopyFromProg();
&test.description = "yeet";
&test.showDesc(); /* Popup string "yeet" */
Based
  • 950
  • 7
  • 18