Msg function

Displays dynamically constructed system messages.

variablereturn = Msg(ownerwindow, msgstructure, msgname, reserved, parameters)

The Msg function has the following parameters.

ParameterDescription
OwnerwindowMsg requires a parent window.

Note: When using an MDIFrame, the ownerwindow will always be the frame regardless of the value passed to the variable.

To display a message without being in event context (for example, if code is executed from the system editor) use the Windows API function MessageBox. This requires SYSTEM MODAL to be set and all string parameters to be terminated with char(0).

An older version of Msg did not require a parent window. This older version is still shipped with OpenInsight in order to support existing software but has been renamed as Msg2. Msg2() is automatically called if the message is displayed outside of event context.
MsgstructureContains the message definition. This structure is detailed table below. If msgname is passed, the message details that are passed in msgstructure are used to override the corresponding parts of the message definition stored in the repository.
MsgnameTo display a message stored in the repository, pass either the name of the message or the message's entity id.
ReservedThis value is reserved; pass "".
ParametersAn @fm-delimited list of substitutable parameter values. Within the message text, the string "%1%" is replaced with the first substitutable parameter, "%2%" is replaced with the second, and so forth.

Note: The Msg function resets the Set_Status() code to zero (0).

Use Msg either for display messages (i.e. error handling) or use it for gathering very small scale user input, as for example with Continue? Yes No situations.

The return value depends on the value passed for the type field of the msgstructure argument.

Note: If you are trying to use the MSG function and the variable you are trying to display contains any system delimiters it may not display correctly. (for example, a message box or button may display with garbled text or won't function properly) What you need to do is use either the CONVERT or SWAP statements. For example:

CONVERT @fm to ',' in VarName

-or-

SWAP @fm with ', ' in VarName

Your message box should now display correctly.

Use the MSG_EQUATES insert record for access to the values in the following table.

Field PositionNamePurpose
1textText to place in Msg dialog box. Multiple lines of text are delimited with "|" (the vertical bar) or @tm. Default is null.
2typeMessage types:

Information Types
Types - Buttons Displayed on Message
BO - OK
BOC - OK/Cancel
BNY - Yes/No
BNYC - Yes/No/Cancel
BRC - Retry/Cancel
BAR - Abort/Retry
BARI - Abort/Retry/Ignore
B{LIST}User defined buttons, where {LIST} is a comma-delimited list of button text, e.g. "BStop,Continue"

Response Types
Type - Description
R - Response message, returning default input if escape pressed.
RC - Same as R, but converting response to upper case.
RCE - Same as RE, but converting response to upper case.
RE - Response message, returning Char(27) if escape pressed.

Timed Types
Type - Description
T{n} - Timed message of n seconds, eg. "T2.5".
TA{n} - Asyncronous timed message (splash screen) of n seconds, eg. "TA10". Note: The message will not close until the engine is idle unless the Yield() function is called.

Processing Types
Type - Description
U - Displays the message and returns immediately (see example below).
D - Closes a processing message; the return value from a U-type message is a D-type message structure which will close the message.

Miscellaneous Types
Type - Description
N - Prefixing any of the message types with "N" suppresses the message display, returning the message's default value. This can be used to change messages from interactive to non-interactive for batch processes; for example, instead of "BARI", pass "NBARI" (meaning don't display the abort/retry/ignore message)
3modalityValue - Description
W - Window. The message's parent window is disabled while the message is displayed.
A - Application. The OpenInsight application is disabled while the message is displayed.
S - System. All windows from all applications are disabled while the message is displayed.
4iconThe image to display on the Msg.

Value - Description
Null - None
* - Asterisk (Info)
? - Question
! - Warning
H - Halt
B - User-specified bitmap (specified in the bitmap field)
5default button1, 2, or 3 depending on number of actual buttons. Response messages don't have a default button; the edit control has the focus. Default is 1.
6colx position to place the dialog box.

A value of -1 centers within the message's parent window.
A value of -2 centers with respect to the screen.
If either col or row is -1 or -2, then the message is centered accordingly, both horizontally and vertically.
7rowy position to place the dialog box.

A value of -1 centers within the message's parent window.
A value of -2 centers with respect to the screen.
If either col or row is -1 or -2, then the message is centered accordingly, both horizontally and vertically.
8justificationMessage text justification.

Justification - Description
T - Text (default). Text Formatting with word wrap.
L - Left
R - Right
C - Center
9bkcolor@VM-delimited list specifying R,G,B background color.

For example: "255:@VM:255:@VM:255" is White, "255:@VM:0:@VM:0" is Red.
Default is white.
10fgcolor@VM-delimited list specifying R,G,B foreground color. Default, "0:@VM:0:@VM:255", is blue.
11text widthThe message width; for response messages, this specifies the response field width.
12captionDialog box caption text. Default is "Message."
13validationValidation pattern to check response message return values against with IN.VALUE. Default is null.
14default inputDefault input to be put into edit control in a response message. (Default is null.)
15mask inputA boolean value used to determine if the input should be masked with asterisks? This is used for password entry.

Value - Description
0 - No masking
1 - Masked
16bitmapName of a bitmap registered in the Repository. Used when icon is set to "B".
17clip bitmapBoolean value, true to clip bitmaps, false to resize; see the IMAGECLIP property for more detail.
18fontFont structure for the text of the message; see the FONT property for more detail.
19literal functionBoolean value. When TRUE the Msg() function assumes that the default value is the name of a function which returns the default value for the message.

For example, if you wrote a function called CURRENTUSER which returned the user name of the current user, you could specify CURRENTUSER as the default value (MDEFINPUT$) and set MLITERAL$ to true, so that the current user name would be the default value for the message; parameters are passed to the specified function depending on the number of parameters that are supported by the function

# of Params - Values Passed in Parameter
0 - None
1 - MsgName
2+ - MsgName, MsgStructure
20helpUsed to add a Help button the message. The structure of the field is an @vm-delimited array of Help information.

Position - Description
<20,1> - Help Type:
Q - QuickHelp. Specify the name of the APPNOTE entitiy.
M - Message. Specify the name of the MSG entity
H - WinHelp. Specify the HelpFile, HelpId
S - Stored Procedure. Specify Procedure Name[, param1..]

<20,2> - Help specifier that is specific to the above Help Types.
<20,3> - Button text. Defaults to "&Help".

Note: Specify the AppNote, Message, HelpFile, or ProcName as it appears in the repository outliner. For example, the OINSIGHT.HLP file is registered as OINSIGHT, so specify the HelpFile as "OINSIGHT" (look in the outline under "General", "Windows Components", "Help Files")
21requiredBoolean value specifying whether a response-type message requires a response; false allows nulls (default) while true doesn't.
22beepAn integer value specifying a system beep. For more information, see MessageBeep in the Windows API.
23extentInteger value representing the number of cycles for the progressbar.
24borderBoolean value specifying whether you want a border around the progressbar.
25smoothBoolean value, set to true to see a smooth progressbar and false to see the segmented progressbar.
26percentBoolean value specifying whether you want to show the percent complete inside the progressbar.
27sync taskbarBoolean value specifying whether you want to mirror the state of the progressbar on the taskbar.
28verticalBoolean value specifying that you want to see a vertical progressbar.
29step valueInteger value representing the number to increment the progressbar by, if not set this value defaults to 1.
30transparencyInteger value from 0 to 100 that sets the transparency of the progressbar with 0 being fully opaque and 100 being fully transparent.
31normal state@vm-delimited list specifying R,G,B progressbar 'normal state' color. Default is Green.
32error state@vm-delimited list specifying R,G,B progressbar 'error state' color. Default is Red.
33paused state@vm-delimited list specifying R,G,B progressbar 'paused state' color. Default is Yellow.
34marqueeInteger value representing time in milliseconds between marquee animation on the progressbar.
35start valueInteger value representing the start value for the gauge, must be between the range values. If not set this value defaults to 1.
36range startInteger value set the lower limit of the progressbar.
37range endInteger value set the upper limit of the progressbar.
38decrementBoolean value, set to true to decrement the progressbar.
39password peekInteger value time in milliseconds to display the entered character before masking password on response messages.
40valid charsCharacters that are valid for response messages.
41animationAnimation file name to use with the progressbar.

Value - Description
FileCopyXP.avi - File Copy
FileMoveXP.avi - File Move
FileDeleteXP.avi - File Delete
FileDestroyXP.avi - File Destroy
FilePropertiesXP.avi - File Properties
EmptyRecyclerXP.avi - Empty Trash
42popup toastBoolean value, for timed messages set to true to see a popup "toast" message in the lower right hand corner of the screen.
43frameSet one of the following values for framestyle of the window.

Value
None
Fixed
Sizeable
Dialog
Fixed Tool
Sizeable Tool
44htmlBoolean value, set to true for HTML text rendering.
45title text fgcolor@vm-delimited list specifying R,G,B main title text color.
46title text bkcolor@vm-delimited list specifying R,G,B main title text color.
47title textMain title text to appear above the regular text.
48mask formatEdit mask format to be used on response line.
49mask typeEdit mask character type required for each character of the edit mask format.

Value - Description
D - A digit
d - A digit or a space
C - An alpha character
c - An alpha character or space
A - An alphanumeric character
a - An alphanumeric character or space
X - A hexadecimal character
x - A hexadecimal character or space
* - Any printable character
+ - A "+" character, a "-" character, or space

Msg() return values are indicated in the following table.

Message TypeReturn Value
BOReturns null if OK clicked, Char(27) if escape pressed.
BOCReturns null if OK clicked, Char(27) if escape pressed or cancel clicked.
BNYReturns 1 if yes clicked, 0 if no clicked, Char(27) if escape pressed.
BNYCReturns 1 if yes clicked, 0 if no clicked, Char(27) if cancel clicked or escape pressed.
BRCReturns 2 if RETRY clicked, Char(27) if Cancel clicked or ESCAPE pressed.
BARReturns 1 if ABORT clicked, 2 if RETRY clicked, Char(27) if ESCAPE pressed.
BARIReturns 1 if ABORT clicked, 2 if RETRY clicked, 3 if IGNORE clicked, Char(27) if ESCAPE pressed.
B{list}1, 2, or 3 for the first, second, or third button (from left to right), Char(27) if ESCAPE pressed.
RReturns entered value if OK pressed, default response if CANCEL clicked or ESCAPE pressed.
REReturns entered value if OK pressed, Char(27) if CANCEL clicked or ESCAPE pressed.
RC, RCEReturns the same as R and RE, except that the response is converted to uppercase.
UReturns a D-type msgstructure that can be passed to a subsequent call of Msg() to take down the processing message.

Example 1: request the user's password (and return it uppercased)

Def = ""

Def<MTEXT$> = "Enter your password:"

Def<MTYPE$> = "RCE"

Def<MICON$> = "?"

Def<MMASKINPUT$> = TRUE$

 

Password = Msg(@window, Def)

if Password = char(27) then

   * user escaped from the message

end else

   * user supplied password (which could be null) and pressed enter

end

Example 2: display a message stored in the repository as "ERROR_MESSAGE"

Text = "An error occurred opening the table for processing."

Msg(@window, Text, "ERROR_MESSAGE")

Example 3: display a message while batch processing

Def = ""

Def<MTEXT$> = "Processing..."

Def<MTYPE$> = "U"

* display the processing message and do the processing

MsgUp = Msg(@window, Def)

gosub BatchProcess

* take down the processing message

Msg(@window, MsgUp)

Example 4: display a gas gauge to show progress while processing 1000 orders

$insert msg_equates

OrderCnt = 1000

Def = ""

Def<MCAPTION$> = "Processing Orders..."

Def<MTYPE$   > = "GC"

Def<MEXTENT$ > = OrderCnt

Def<MTEXTWIDTH$ > = 400

MsgUp = Msg(@window, Def)

for Order = 1 to OrderCnt

    /*  process the order */

    * update the gauge and check if cancel was pressed

while Msg(@window, MsgUp, Order, MSGINSTUPDATE$)

next Order

/*  we are done, take down the gas gauge */

Msg(@window, MsgUp)         ;* take down the gauge

Example 5: logon processing with a batch screen

Def = ""

Def<MTYPE$> = "TA5"

 

* display 5-second splash-screen while performing login processing

Msg(@window, Def, "SPLASHSCREEN")

gosub Logon_Process

* allow the message to close if 5 seconds have elapsed

Yield()

gosub Setup

Example 6: password response message using a peek time of 200 milliseconds

              Def ='' 

              Def<MTEXT$     > = "Enter Password"

              Def<MTYPE$     > = "RE"

              Def<MICON$     > = "?"

              Def<MCAPTION$  > = "Password Style Response"

              Def<MMASKINPUT$> = 1

              Def<MPWDPEEK$  > = 200

              MsgUp = Msg(@window, Def)

Example 7: response message with valid character being abcd1234

              Def =''

              Def<MTEXT$      > = "Valid characters are abcd1234"

              Def<MTYPE$      > = "RE"

              Def<MICON$      > = "!"

              Def<MCAPTION$   > = "Valid CHAR Response Message"

              Def<MVALIDCHARS$> = "abcd1234"

              MsgUp = Msg(@window, Def)

Example 8: response message with a date edit mask

              Def =''

              Def<MTEXT$      > = "Please enter date of response"

              Def<MTYPE$      > = "RE"

              Def<MICON$      > = "?"

              Def<MCAPTION$   > = "Edit Mask Response Message"

              Def<MMASKFORMAT$> = "__/__/____"

              Def<MMASKTYPE$  > = "dd dd dddd"

              MsgUp = Msg(@window, Def)

Example 9: display a message containing title text and html

              Def ='' 

              Def<MTEXT$    > = "<b>Processing using Title Text and HTML</b>"

              Def<MTYPE$    > = "U"

              Def<MCAPTION$ > = "Processing Message "

              Def<MHTML$    > = 1

              Def<MMAINTEXT$> = "Main Title Text"

              MsgUp = Msg(@window, Def)

              Delay(5)

              * take down the processing message

              Msg(@window, MsgUp)

Example 10: display a timed 'pop-up toast' type of message

              Def ='' 

              Def<MTEXT$   > = "Your file has been sent..."

              Def<MTYPE$   > = "T5"

              Def<MICON$   > = "*"

              Def<MCAPTION$> = "Timed 'Pop-up Toast' Message"

              Def<MPOPUP$  > = 1

              MsgUp = Msg(@window, Def)

Example 11: display a progress bar message

              Def ='' 

              Def<MTEXT$> = "Incudes Border, Taskbar Sync, Show Percentage Complete and Smooth options"

              Def<MTYPE$> = "GCY"

              Def<MICON$> = "*"

              Def<MCAPTION$> = "Progress Bar Message"

              Def<MGBORDER$> = 1

              Def<MGSMOOTH$> = 1

              Def<MGPERCOMPLETE$> = 1

              Def<MGSYNCTASK$> = 1

              Def<MGRANGESTART$> = 1

              Def<MGRANGEEND$> = 1000

              Def<MANIMATE$> = "FileCopyXP.avi"

              MsgUp = Msg(@window, Def)

              for i = Def<MGRANGESTART$> to Def<MGRANGEEND$>

                 * do processing here

                 Delay(4/Def<MGRANGEEND$>)

              While Msg(@Window, MsgUp, i, MSGINSTUPDATE$)

                 * get the state of the progress bar

                 state = Get_Property("MSG.EB_RESP", "STATE")

                 * if paused loop until state is changed

                 if state = 3 Then

                    loop

                       pause_status = Get_Property("MSG.EB_RESP", "STATE")

                    While pause_status = 3

                       call Yield()

                    Repeat

                 end

             next i

             * Clear progress on taskbar icon

             val = Set_Property("MSG.EB_RESP", "SYNCTASKBAR", 0)

             * we are done, take down the progress bar

             Msg(@window, MsgUp)

             Return

Example 12: display a vertical progress bar message

             Def ='' 

             Def<MTEXT$       > = "Vertical progress bar using the decrement option"

             Def<MTYPE$       > = "GCY"

             Def<MICON$       > = "!"

             Def<MTEXTWIDTH$  > = 500

             Def<MCAPTION$    > = "Progress Bar Vertical Message"

             Def<MGVERTICAL$  > = 1

             Def<MGRANGESTART$> = 1

             Def<MGRANGEEND$  > = 1000

             Def<MGDECREMENT$ > = 1

             MsgUp = Msg(@window, Def)

             for i = Def<MGRANGESTART$> to Def<MGRANGEEND$>

                * do processing here

                Delay(4/Def<MGRANGEEND$>)

             While Msg(@Window, MsgUp, i, MSGINSTUPDATE$, Def<MGDECREMENT$>) ;* pass in DECREMENT flag

                * get the state of the progress bar

                state = Get_Property("MSG.EB_RESP", "STATE")

                * if paused loop until state is changed

                if state = 3 Then

                   loop

                      pause_status = Get_Property("MSG.EB_RESP", "STATE")

                   While pause_status = 3

                      call Yield()

                   Repeat

                end

             next i

             * we are done, take down the progress bar

             Msg(@window, MsgUp)
  • guides/programming/programmers_reference_manual/msg.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1