Msg2


The Msg2 function opens a medium size dialog to show a message. An example is shown below.

 

Syntax

bOK = Msg2( string, sTitle=nil )

bullet.gif    string is the message to display and may contain multiple lines.

bullet.gif    sTitle is the optional title of the dialog. If nil, a default is used.

bullet.gif    This function returns bOK=true if the [OK] button is clicked.

bullet.gif    If the dialog is canceled, false is returned.

Remarks

The Msg2 window is a simple dialog that shows a message and returns the clicked button as boolean true/false. The script can use the returned value to make a decision after showing the message. If the message requires arguments to be formatted, use Sprintf to do the formatting in place of the string argument to Msg2 (see below).

The edit control supports cut, copy, and paste, should you need to interact with the text displayed in the message. It also scrolls if the message is larger than the visible area.

The related Msg function is similar but opens a small window. Both Msg and Msg2 use a modal message box which must be closed before the script can continue. If a modal message box is not needed, you can also use the Printf function to format text to a scrolling Edit window.

If the string uses multiple lines, the string should be formatting using the \r\n escape sequence (the so-called carriage return / line feed pair) to separate the lines.

Example

The following code opens the message window after formatting some text using Sprintf. This statement resulted in the window shown above. Notice the use of the .. operator to concatenate the format string, which is then spread over multiple lines for greater readability.

 

str = Sprintf( "Image Cursor 1:\r\nExtent = " ..

                  "%.2lf:%.2lf, %.2lf:%.2lf\r\n" ..

                  "Position= %.3lf %.3lf, success=%d\r\n" ..

                  "Style= %d, success=%d\r\n\r\n",

                  R:Xmin(), R:Xmax(), R:Ymin(), R:Ymax(),

                  x, y, bOK1, nStyle, bOK2 )

bOK = Msg2( str )

Related Topics

Msg, Printf


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.