GuidoFunction
Overview
The GuidoFunction command is a general purpose utility for performing miscellaneous functions in Guido scripts. It is an advanced function that is only applicable when used in call-back procedures, see Guido Call-backs for information on call-backs.
Presently the function only supports two functions but this will increase into the future as needed. The getComponentByName function will find the named Guido object in the form definition and will return a reference handle to it such that Guido object methods can be invoked. The translate function will perform a multi lingual translation on the given text.
Synopsis
GuidoFunction subFunction [arguments]
Description
GuidoFunction will run the requested sub-function and return a value that is dependant on the sub-function. It may be an object handle or a string result.
Arguments
subFunction subFunction is the name of the sub-function you wish to run
arguments arguments are any additional parameters that the sub function may require
GuidoFunction Sub-functions
| getComponentByName componentName $container | getComponentByName returns
a reference handle to the Guido object identified by the given name if it can be found in the container object.
If the name cannot be found an empty string is returned.
set scroller [GuidoFunction getComponentByName "tableScroll" $form] set maxField [GuidoFunction getComponentByName "maximum" $paramTable] set mainHandle [GuidoFunction getComponentByName "mainPanel" $plotForm] |
| translate key [arguments] | translate returns a valid
translation for the given key. The key maybe standard English text or
could be a MTL (Multi Lingual Translator) key. Some keys may require arguments
to be passed through that will be included in the translation.
set message [GuidoFunction translate "Enter location"] set tip [GuidoFunction getComponentByName MS::RINGKING_TIP1] set msg [GuidoFunction getComponentByName "file not found" "pit1.str"] |
Examples
Example 1
The example form below contains a button that will call a form procedure that will make use of the GuidoFunction command to print some messages.
# GuidoFunction Example 1
# define the form
set formDef {
# a form proc to test GuidoFunction
proc runGuidoFunction {} {
global form
# find the button by its name
set button [GuidoFunction getComponentByName "goButton" $form]
if {[string length $button]} {
puts "This name '[$button getName]' should the same as this name 'goButton'"
} else {
puts "Error cannot find goButton component"
}
# try a simple MLT conversion
set abr [GuidoFunction translate ABBREVIATION_FOR_ADJUSTMENT]
puts "The abbreviation for adjustment is $abr"
# try a conversion with a parameter
set msg [GuidoFunction translate FIO_ACCESS_ERR "afile.txt"]
puts $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 {[runGuidoFunction]}
}
GuidoFiller fil1 {
-height 1
}
}
}
# Create and run the form
SclCreateGuidoForm formHandle $formDef {}
$formHandle SclRun {}
|
See Also
Guido
Dependency Callbacks
Action Callbacks
Validation Callbacks