Msg function
Description
Displays dynamically constructed system messages.
Syntax
variablereturn = Msg(ownerwindow, msgstructure, msgname, reserved, parameters)
Parameters
The Msg function has the following parameters.
Parameter | Description |
---|---|
Ownerwindow | Msg 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. |
Msgstructure | Contains 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. |
Msgname | To display a message stored in the repository, pass either the name of the message or the message's entity id. |
Reserved | This value is reserved; pass "". |
Parameters | An @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. |
Remarks
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.
Message Structure
Use the MSG_EQUATES insert record for access to the values in the following table.
Field Position | Name | Purpose |
---|---|---|
1 | text | Text to place in Msg dialog box. Multiple lines of text are delimited with "|" (the vertical bar) or @tm. Default is null. |
2 | type | Message 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) |
3 | modality | Value - 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. |
4 | icon | The 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) |
5 | default button | 1, 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. |
6 | col | x 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. |
7 | row | y 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. |
8 | justification | Message text justification. Justification - Description T - Text (default). Text Formatting with word wrap. L - Left R - Right C - Center |
9 | bkcolor | @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. |
10 | fgcolor | @VM-delimited list specifying R,G,B foreground color. Default, "0:@VM:0:@VM:255", is blue. |
11 | text width | The message width; for response messages, this specifies the response field width. |
12 | caption | Dialog box caption text. Default is "Message." |
13 | validation | Validation pattern to check response message return values against with IN.VALUE. Default is null. |
14 | default input | Default input to be put into edit control in a response message. (Default is null.) |
15 | mask input | A 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 |
16 | bitmap | Name of a bitmap registered in the Repository. Used when icon is set to "B". |
17 | clip bitmap | Boolean value, true to clip bitmaps, false to resize; see the IMAGECLIP property for more detail. |
18 | font | Font structure for the text of the message; see the FONT property for more detail. |
19 | literal function | Boolean 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 |
20 | help | Used 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") |
21 | required | Boolean value specifying whether a response-type message requires a response; false allows nulls (default) while true doesn't. |
22 | beep | An integer value specifying a system beep. For more information, see MessageBeep in the Windows API. |
23 | extent | Integer value representing the number of cycles for the progressbar. |
24 | border | Boolean value specifying whether you want a border around the progressbar. |
25 | smooth | Boolean value, set to true to see a smooth progressbar and false to see the segmented progressbar. |
26 | percent | Boolean value specifying whether you want to show the percent complete inside the progressbar. |
27 | sync taskbar | Boolean value specifying whether you want to mirror the state of the progressbar on the taskbar. |
28 | vertical | Boolean value specifying that you want to see a vertical progressbar. |
29 | step value | Integer value representing the number to increment the progressbar by, if not set this value defaults to 1. |
30 | transparency | Integer value from 0 to 100 that sets the transparency of the progressbar with 0 being fully opaque and 100 being fully transparent. |
31 | normal state | @vm-delimited list specifying R,G,B progressbar 'normal state' color. Default is Green. |
32 | error state | @vm-delimited list specifying R,G,B progressbar 'error state' color. Default is Red. |
33 | paused state | @vm-delimited list specifying R,G,B progressbar 'paused state' color. Default is Yellow. |
34 | marquee | Integer value representing time in milliseconds between marquee animation on the progressbar. |
35 | start value | Integer value representing the start value for the gauge, must be between the range values. If not set this value defaults to 1. |
36 | range start | Integer value set the lower limit of the progressbar. |
37 | range end | Integer value set the upper limit of the progressbar. |
38 | decrement | Boolean value, set to true to decrement the progressbar. |
39 | password peek | Integer value time in milliseconds to display the entered character before masking password on response messages. |
40 | valid chars | Characters that are valid for response messages. |
41 | animation | Animation 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 |
42 | popup toast | Boolean value, for timed messages set to true to see a popup "toast" message in the lower right hand corner of the screen. |
43 | frame | Set one of the following values for framestyle of the window. Value None Fixed Sizeable Dialog Fixed Tool Sizeable Tool |
44 | html | Boolean value, set to true for HTML text rendering. |
45 | title text fgcolor | @vm-delimited list specifying R,G,B main title text color. |
46 | title text bkcolor | @vm-delimited list specifying R,G,B main title text color. |
47 | title text | Main title text to appear above the regular text. |
48 | mask format | Edit mask format to be used on response line. |
49 | mask type | Edit 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 |
Returns
Msg() return values are indicated in the following table.
Message Type | Return Value |
---|---|
BO | Returns null if OK clicked, Char(27) if escape pressed. |
BOC | Returns null if OK clicked, Char(27) if escape pressed or cancel clicked. |
BNY | Returns 1 if yes clicked, 0 if no clicked, Char(27) if escape pressed. |
BNYC | Returns 1 if yes clicked, 0 if no clicked, Char(27) if cancel clicked or escape pressed. |
BRC | Returns 2 if RETRY clicked, Char(27) if Cancel clicked or ESCAPE pressed. |
BAR | Returns 1 if ABORT clicked, 2 if RETRY clicked, Char(27) if ESCAPE pressed. |
BARI | Returns 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. |
R | Returns entered value if OK pressed, default response if CANCEL clicked or ESCAPE pressed. |
RE | Returns entered value if OK pressed, Char(27) if CANCEL clicked or ESCAPE pressed. |
RC, RCE | Returns the same as R and RE, except that the response is converted to uppercase. |
U | Returns a D-type msgstructure that can be passed to a subsequent call of Msg() to take down the processing message. |
Examples
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)