20. Writing 4GL Statements : Forms-Control Statements : Displaying Messages and Prompts
 
Share this page                  
Displaying Messages and Prompts
Messages and prompts let you communicate with the user of the frame at run time. The statements are:
message message [with style = menuline | popup [option]]answer = prompt message [with style = menuline | popup [option]]
The message statement displays a single or multi‑line text string in the window, either on the menu line or in a pop‑up box, depending on the message style you specify.
For menu-line display, either use the message statement alone, as in the following examples, or use the optional clause: with style= menuline. A convenient use of the message statement is immediately before a query statement:
message 'Retrieving employee data';
query statement;
A menu‑line style message followed by a query statement stays on the frame until control is returned to the user. To control the length of time the menu line message remains in the window, use a sleep statement along with the menu‑line message statement, as in this example:
message 'That field must contain a number'; 
sleep 5;
Use pop‑up style if you want to ensure that the user sees a message. The instruction "Press Return" is automatically appended to a message displayed in a pop‑up box. The message stays in the window until the user presses Return.
A prompt statement requests input from the user. The prompt displays a character string in the window, then accepts user input and assigns it to the specified field or variable, as shown in the example below:
repname = prompt 'Enter the report name: ';
When the user responds to this prompt at run time, the specified report name is assigned to the Repname field.
You can also use a prompt when you want to make sure the user sees a message. The user must respond to a prompt with a keystroke before the program proceeds. Tell the user to press the Return key here if no other response is needed.
Pop-up Messages
Use the message statement with the with style clause to display messages in a pop-up box. The message appears in a box on top of the currently displayed frame. This example displays a message in pop-up style at the current cursor position:
message :errorbuf 
  with style = popup (floating);
The rest of the frame remains intact. When the user presses Return, the pop-up message box disappears and the frame returns to its previous state.
You can position the pop-up box anywhere in the window, depending on the size of the pop-up. For example, the following statement causes the prompt (in quotes) to appear in a pop‑up box in the upper left-hand area of the frame. The number coordinates place the top left hand corner of the box in the second column and the eighth row.
Message 'An error has occurred'
  with style = popup (startcolumn = 2, 
  startrow = 8);
To specify the dimensions of the message box, use a statement like this:
message 'An error has occurred'
  with style = popup (rows = 12, 
  columns = 25);
This statement produces a box that is 12 rows in height and 25 columns in width.