TclScript
star. The TkShowValues
star used in example
1 on page 5-2 is such a star. That star takes inputs of any type and displays their value in a window that is optionally located in the control panel. It has three parameters (settable states):
TclScript
star from which this is derived. The file is hard-wired into the definition of the star by the following C++ statement included in the setup method:
A second issue is that of communicating the new parameter values to the Tcl script. For example, the Tcl script will need to know the value of the label parameter in order to create the label for the display. The
TclScript
star automatically makes all the parameters of any derived star available as array entries in the global array whose name is given by the global variable starID.
To read the value of the label parameter in the Tcl script, use the expression [set ${starID}(label)]
. The confusing syntax is required to ensure that Tcl uses the value of starID
as the name of the array. The string "label" is just the index into the array. The set
command in Tcl, when given only one argument, returns the value of the variable whose name is given by the argument.Some programmers may prefer an alternative way to refer to parameters that is slightly more readable. The Tcl statement
$param(param_name)
. The upvar
command with argument #0
declares the local variable params
equivalent to the global variable whose name is given by the value of starID.
Many more examples can be found in
$PTOLEMY/src/domains/sdf/tcltk/stars
.