Tcl Bean
Remote Places to go:
Local Places to go:
Contents:
NOTE:
This page is somewhat out of date. Tcl Blend 1.2 probably won't
have the Tcl Bean in it, it will be removed.
The Tcl Bean is a Java Bean for use with Sun's Java Studio. The Tcl
Bean provides two main features:
- Dynamic allocation of Bean ports from a Tcl Script
- Bean Customizers using Tcl Blend scripts that call java.awt methods
Java Beans have control panels called Customizers that are used
to set Bean parameters like the name of the bean and the names of the
connections. Using a Tcl scripts to develop the Customizer is much
faster that writing Java code, compiling it, reloading it into Java
Studio and testing it. With a Tcl script implementation of the
customizer, modifications can be made and tested on-the-fly.
The Tcl Bean will work with either Jacl or Tcl Blend. I found it
easier to get started with Jacl and then to try out Tcl Blend.
Tcl Bean under Windows with Jacl
- Download and install
Sun Java Studio
- Download and install Jacl from the Scriptics Jacl and Tcl Blend page
- Start up Java Studio to create a
js10
directory
in your home directory, which varies from machine to machine.
A typical location is c:\js10
.
Find your js10
directory and make a directory called
js10\PlugIns\classes
.
- In the directory where you installed Jacl, find the
jacl.jar
and tclbean.jar
files. Copy these two jar files
to js10\PlugIns\classes
- You will need to expand the
jacl.jar
file, so
start up a shell and do
cd js10\PlugIns\classes
jar xf jacl.jar
- In the Java Studio toolbar window, import
the
js10\PlugIns\classes\tclbean.jar
file by
selecting Import
-> Java Beans
Tcl Bean under Windows with Tcl Blend
The Tcl Bean instructions say to use Tcl Blend.
- If you have not yet done so, download and install
Sun Java Studio
- Follow the instructions in
tclbean_install.txt
and
README
Tcl Bean under Window Hints
Getting Tcl Blend and the Tcl Bean to work can be a little tricky. If
you have problems, try using Jacl instead of Tcl Blend.
If you have problems, look in js10\vj\VJLog
for hints.
To get the Tcl bean to install, I had to set my Path so that
tclblend.dll
was in it. Locally, this file is in
C:\Program Files\Tcl\lib\tclblend1.1
.
Without this change, I got messages about Link errors in
line 132 of Interp.java because the create
method
could not be loaded.
- Download
Sun Java Studio
- Follow the instructions in
tclbean_install.txt
and
README
- Locally, I did the following
unsetenv LD_LIBRARY_PATH
mkdir -p .js1.0/PlugIns/classes
cd .js1.0/PlugIns/classes
ln -s /users/ptdesign/obj.sol2.5/jacl1.1/jacl.jar .
ln -s /users/ptdesign/obj.sol2.5/tcltk/tclBlend1.0up2/tclbean.jar .
jar -xf jacl.jar
/users/ptdesign/vendors/sun/Java-Studio1.0/JS/sparc-S2/bin/js
Once you have installed the Tcl Bean, you can start experimenting with
it. The Tcl Bean is usually installed in the User
palette.
The Tcl Bean icon has the Tcl feather in it.
Looking at the Tcl Bean features
- Java Studio has three windows: a toolbar, a GUI window and a design
window. In the toolbar window, select the
User
thumbtab,
click on the Tcl Interp Tcl Bean and then click on the GUI window.
- You will get a message about how the Tcl Interp1 component
does not have a graphical representation. Click on OK.
Click on OK in the next dialog as well
- The Tcl Interp icon will appear in the design window, and
the Tcl Interp Customizer window will come up.
- The Tcl Interp Customizer window has a
Variables
thumbtab that has a File
entry field which can be used
to load a Tcl file into the Script
text widget below.
There is also and a Browse
button and a combo box
that lists predefined scripts.
- The predefined scripts are worth looking at. In the combo box,
Select each script in turn and then hit apply. Below
is a description of each script
-
choiceValue.tcl
- Simple example that prints the
toString
value of the
input. This script probably should not be part of the release.
-
distrib.tcl
- A Tcl Bean implementation of the Java Studio Distrib bean.
-
eval.tcl
- Reads in a string, evaluates it and sends the results to the output.
(Note that the comment at the top is probably wrong, it is a duplicate
of the comment in
memory.tcl
below)
-
exec.tcl
- Uses the Tcl
exec
command to run ls
and cat
. This script is likely to have problems under
Windows unless you have ls
and cat
.
-
inspect.tcl
- Reads a Tcl handle to a Java object and then prints out
informatin about the object using
java::info
.
-
memory.tcl
- Tcl Bean implementation of the Memory bean that is shipped
with Java Studio
-
switch.tcl
- Tcl Bean implementation of the Switch bean that is shipped
with Java Studio.
The Switch bean is like the Tcl
switch
command:
switch $foo {
a {puts "foo is an a"}
b {puts "foo is an b"}
default {puts "I have no idea what foo is"}
}
An input value is checked against values associated with an output
connector. If the values match, then a second input value is
set to the output connector. If the input value does not match
any of the values associated with the output connectors, then
the second input value goes to the default output connector
-
customDistrib.tcl
- Read an input and distributes it to user defined outputs.
This script is an example of how Tcl Beans can modify the Customizer.
The customizer allows the user to choose the name, description
and location of the output(s)
-
customMemory.tcl
- This script uses a customizer that
allows the user to choose what values the bean stores.
-
customSwitch.tcl
- This script uses a customizer that
allows the user to choose the values and orientations of the
output connectors.
Problems with Tcl Bean applications under Windows
I saved the Example as an application.
ErrorBean.tcl
contains
a Tcl Bean that will print the Java stack if there is an error.
Searching the
Java Studio FAQ
for CLASSPATH
yields:
When I try to import a component into JS, I get "Unable to load JAR file". .
On Microsoft Windows systems:
C:> js -classpath -your_classpath
Notice the hyphen before your_classpath.
On UNIX systems:
% js "-classpath your_classpath"
Unfortunately, those instructions do not seem to work under Windows.
I also tried setting the CLASSPATH
and TCL_CLASSPATH
variable from within a Tcl Bean, but that did not work.
The Tcl Bean classes are installed in js10\PlugIns\classes
.
Placing the Java .class files below that directory seems to work.
Customizers are Java Studio graphical user interfaces to Beans. See the
studiocustom::custom
documentation for details
Last updated: 10/09/05,
cxh at eecs