RATS 10.1
RATS 10.1

Instructions /

MESSAGEBOX Instruction

Home Page

← Previous Next →

MESSAGEBOX( options )   "messagestring"

MESSAGEBOX displays a message in a dialog box, and waits for the user to respond to the message. There are four types of dialog boxes from which to choose—they differ only in the responses available to the user. For more complex dialogs, use the DBOX or MENU/CHOICE instructions.

Parameters

"messagestring"

This is the string that will be displayed in the dialog box. This can be a string enclosed in quotes, or a LABEL or STRING type variable.
 

For a long message, MESSAGEBOX will automatically wrap lines to keep the width reasonable. If you want to control breaks yourself, insert the characters \\\\ where you want a line break.

Options

STYLE=[ALERT]/OKCANCEL/YESNO/YNCANCEL

This determines which responses (in the form of buttons) are available for the user, and which STATUS codes are returned by the various buttons. See the table below.
 

DEFAULT=default choice for STYLE=YESNO [1=yes]

If you use STYLE=YESNO, you can use DEFAULT=0 if you want the "No" button to be the default, rather than the "Yes" button.

 

STATUS=status code returned (INTEGER)

STATUS returns an integer code indicating which of the available buttons the user selected. Listed below are the STYLE options, buttons displayed, and codes returned by the STATUS option:
 

Option

Buttons

Status Returned

STYLE=ALERT

OK

1

STYLE=OKCANCEL

OK

1

 

Cancel

0

STYLE=YESNO

Yes

1

 

No

0

STYLE=YNCANCEL

Yes

1

 

No

0

 

Cancel

-1

Examples

messagebox(style=yesno,status=yn) "View the residuals?"

if yn==1

  {

  graph(header="Regression Residuals") 1

  # %resids

  }

 

will display the following dialog:


 


If the user clicks on the “Yes” button, RATS will execute the GRAPH instruction.

 

 

This next uses a MESSAGEBOX to ask the user if the current degrees of freedom value (stored in DGF) is correct. If the user responds “Yes”, the rest of the code is skipped. If the user answers “No”, a QUERY instruction prompts the user to input a new value. The VERIFY option requires the user to supply a valid (greater than –1) value.


 

if %BFlag == 1 {

   messagebox(sty=yesno,status=Stop) "Calculated "+%string(dgf)+ $

     " degrees of freedom. Is this correct?"

   * If "No", use QUERY to have user input a value for DGF:

   if Stop == 0  {

       query(prompt="Input correct degrees of freedom", $

          verify=(dgf>-1),error="Value must be larger than -1") dgf

   }

}

 


Copyright © 2025 Thomas A. Doan