[tcljava-user] Tclblend loading dlls
Brought to you by:
mdejong
From: Tam H. <th...@su...> - 2001-05-18 01:18:19
|
Thanks Mo for the exception handling. But the load didn't work in the main application itself, so i tried calling in a separate java file instead. Ok so why does my java application result in an exception whenever the simple.tcl call the command "test". The gcd function should be already loaded since my "load" was executed. Why is this not the case? This script execute fine in the tclsh but the main java program does not when i tried calling the simple.tcl. What i'm doing wrong or not understanding? exception: invalid command "test" /*main java program Demo1.java using Forte for Java*/ public static void main(String args[]) { try { String myfile = "source d:/Tcl83/lib/test/simple.tcl"; Interp newInterp = new Interp(); newInterp.eval(myfile); newInterp.dispose(); } catch(TclException e) { int code = e.getCompletionCode(); if(code == TCL.ERROR) { System.err.println(newInterp.getResult().toString()); } else { System.err.println("command return bad" + code); } } } /*SimpleExtension.java*/ import tcl.lang.*; public class SimpleExtension extends Extension { public void init(Interp interp) { interp.createCommand("test", new testex()); } } /*testex.java*/ import tcl.lang.*; class testex implements Command { public void cmdProc(Interp interp, TclObject argv[]) throws TclException { interp.eval("load " + "example.dll"); } } /*simple.tcl*/ package require java java::load -classpath . SimpleExtension test set f "log.txt" set out [open $f w] set x 42 set y 105 set g [gcd $x $y] puts $out $g close $out |