Download RAD6 trial from:
http://www-128.ibm.com/developerworks/downloads/r/rad/?S_TACT=105AGX14&S_CMP=DWNL
Start RAD6 or Eclipse 3.1.
1. Create Java project.
2. Add the JACL jar files.
Add jacl.jar and tcljava.jar to the java build path under "project
properties". The jar files are already packaged with RAD6 and can be
found under the install directory e.g.
"D:\IBM\Rational\ADTrial\6.0\runtimes\base_v6\lib\jacl.jar".
3. Create a top level java class.
Create a top level java class with a main method. Instantiate the tcl
interpreter and use the Interp eval method to either run Tcl in-line or
source Tcl from a file.
Example.
*********
Run the tcl command in-line "puts [clock format [clock seconds] -format
%k:%M:%S]"
Source the proc compare.
proc compare {howmany value} {
for {set i 1} {$i < $howmany} {incr i} {
if {$i == $value} {
puts $i
}
}
}
set bench 1000
set bench2 [expr $bench - 1]
puts "comparing an int against $bench others..."
compare $bench $bench2
##############################################################################
import tcl.lang.*;
// Java wrapper to test JACL under RAD 6.
public class ScriptRunnerTcl {
public static void main(String []args) {
Interp i = new Interp();
try {
i.eval("set x {The time is }");
i.eval("set y [clock format [clock seconds] -format
%k:%M:%S]");
i.eval("puts [append z $x $y]");
i.eval("puts \\n");
} catch (TclException e) {
System.out.println("Exception: " + e.getMessage());
}
try {
i.eval("source E:/scripts/TCL/jacl/compare.tcl");
} catch (TclException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
#############################################################################
The output looks like:
The time is 21:19:51
comparing an int against 1000 others...
999
AFAIR there were some questions around this in the recent past. To
not get lost, it would be nice if you put it into the Wiki at
http://wiki.tcl.tk/
Thank you very much!
--
Matthias Kraft
Software AG, Germany
(They that can give up essential liberty to obtain a little temporary)
(safety deserve neither liberty nor safety. -- Benjamin Franklin)
Done. "http://wiki.tcl.tk/1637"