GuidoMessage
Overview
The GuidoMessage command provides access to the software's messaging system to display information in the message window. It can also be used to translate messages into the local language if the language is supported
Synopsis
GuidoMessage subFunction messageKey [arguments]
Description
The GuidoMessage command allows you to print information into the message window in a variety of formats by specifying a sub-function. The available sub-functions are given in the table below
Arguments
subFunction subFunction is the name of the sub-function you wish to run
messageKey The message text that may include optional argument place holders to be substituted for actual arguments specified in the optional parameters section. The message text may also be a MLT key that the system will substitute for the translated text.
arguments arguments are any additional parameters that the sub-function may require
GuidoMessage Sub-functions
Print the message key text into the message window. If optional
arguments are given they will be formatted into the message text as described below
GuidoMessage print "Macro has complete successfully" |
|
| message | Same as print
GuidoMessage message "Another way to print a message" |
| debug | Print the message key text as a debug message. If debug messages
are currently disabled via the Message Options settings then it will be
filtered out and nothing will be visible in the message window
GuidoMessage debug "Reached point A in the macro, were is my bug" |
| warning | Print the message key text as a warning message. If warning
messages are currently disabled via the Message Options settings then
it will be filtered out and nothing will be visible in the message window
GuidoMessage warning "Macro cancelled" |
| error | Print the message key text as an error message. If the Beep
for error messages option is set via the Message Options settings then
the computers bell will also ring.
GuidoMessage error "Macro has complete successfully" |
| translate | The translate option will format the message key and any
of the optional arguments that may be specified and return the formatted
text. This option does not display the message to the message window
set msg [GuidoMessage translate "File {0} not found in {1}" "pit1.str" “srv"]
|
Argument Substitution
The message key argument that is passed to GuidoMessage can contain optional argument place holders that take the form {0}, {1}, {2}, ... These place holders will be replaced with optional arguments that you provide to GuidoMessage. The place holder {0} will be substituted with the first optional argument, {1} with the second argument, and so on.
An example that assumes 3 variables called strNo, segNo, and pntNo exist previously and contain the values 100, 5, and 65 respectively.
GuidoMessage print "Processing string {0}, segment {1}, point number {2}" $strNo $segNo $pntNo
will produce the message
Processing string 100, segment 5, point number 65
Another Example that show the arguments holders can be mixed up through the message key:
GuidoMessage print "String {0} : {2} points processing on segment {1} of string {0}" $strNo $segNo $pntNo
will produce the message
String 100 : 65 points processing on segment 5 of string 100
An example that shows if you specify more place holders than arguments then the place holder remains unsubstituted in the message
GuidoMessage print "Processing string {0}, segment {1}, point number {2}" $strNo $segNo
will produce the message
Processing string 100, segment 5, point number {2}
Examples
Example 1
The example form below contains a button that will call a form procedure that will make use of the GuidoMessage command to print some messages.
# GuidoMessage Example 1
# define the form
set formDef {
# a form proc to test GuidoMessage
proc runGuidoMessage {} {
GuidoMessage message "A standard message"
GuidoMessage debug "Reached debug point A, were is my bug"
GuidoMessage warning "Macro cancelled"
GuidoMessage error "Use this for serious errors"
set msg [GuidoMessage translate "File {0} not found in {1}" "pit1.str" "srv"]
puts "A translated message--> $msg"
}
GuidoForm form {
-label "Using Menu Components"
-default_buttons
-layout BoxLayout Y_AXIS
GuidoFiller fil1 {
-height 1
}
GuidoButton goButton {
-caption "Press for some action"
-width 25
-action valueChanged {[runGuidoMessage]}
}
GuidoFiller fil1 {
-height 1
}
}
}
# Create and run the form
SclCreateGuidoForm formHandle $formDef {}
$formHandle SclRun {}
|
See Also
Guido
Dependency Callbacks
Action Callbacks
Validation Callbacks