tcljava-user Mailing List for Tcl/Java (Page 13)
Brought to you by:
mdejong
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(23) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(12) |
Feb
(10) |
Mar
(16) |
Apr
(10) |
May
(40) |
Jun
(13) |
Jul
(18) |
Aug
(4) |
Sep
(6) |
Oct
(3) |
Nov
|
Dec
(3) |
2002 |
Jan
(15) |
Feb
(19) |
Mar
(1) |
Apr
(11) |
May
(12) |
Jun
(10) |
Jul
(2) |
Aug
(22) |
Sep
|
Oct
(3) |
Nov
(9) |
Dec
(20) |
2003 |
Jan
(32) |
Feb
(5) |
Mar
(26) |
Apr
(30) |
May
(10) |
Jun
(8) |
Jul
(17) |
Aug
(7) |
Sep
(24) |
Oct
(7) |
Nov
(6) |
Dec
|
2004 |
Jan
(5) |
Feb
|
Mar
|
Apr
(7) |
May
(8) |
Jun
(12) |
Jul
(3) |
Aug
(11) |
Sep
(8) |
Oct
(4) |
Nov
(2) |
Dec
(6) |
2005 |
Jan
(8) |
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
(19) |
Jul
(8) |
Aug
(22) |
Sep
(12) |
Oct
(35) |
Nov
(12) |
Dec
(4) |
2006 |
Jan
(20) |
Feb
(14) |
Mar
(23) |
Apr
(10) |
May
(11) |
Jun
(1) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(17) |
Dec
(10) |
2007 |
Jan
(41) |
Feb
(6) |
Mar
(23) |
Apr
(15) |
May
(34) |
Jun
(5) |
Jul
(18) |
Aug
(13) |
Sep
(8) |
Oct
(9) |
Nov
(7) |
Dec
(2) |
2008 |
Jan
|
Feb
(1) |
Mar
(18) |
Apr
(1) |
May
(1) |
Jun
(10) |
Jul
(3) |
Aug
|
Sep
(10) |
Oct
(3) |
Nov
(13) |
Dec
(3) |
2009 |
Jan
(4) |
Feb
(10) |
Mar
(1) |
Apr
(11) |
May
(3) |
Jun
(7) |
Jul
(4) |
Aug
(9) |
Sep
(16) |
Oct
(3) |
Nov
(5) |
Dec
(2) |
2010 |
Jan
(3) |
Feb
|
Mar
|
Apr
(7) |
May
(1) |
Jun
|
Jul
|
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
2011 |
Jan
(3) |
Feb
|
Mar
(2) |
Apr
(17) |
May
(4) |
Jun
(17) |
Jul
(5) |
Aug
(7) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
(12) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(1) |
Jul
|
Aug
(3) |
Sep
(2) |
Oct
(6) |
Nov
|
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
(1) |
May
(8) |
Jun
(1) |
Jul
|
Aug
(3) |
Sep
|
Oct
(3) |
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
(1) |
Jun
(3) |
Jul
(3) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2018 |
Jan
|
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: rohit <roh...@ya...> - 2007-10-03 07:37:42
|
thanks, all for your responses i got what i was looking for after looking into GUIShell.java and google-ing a bit lines below were added to my java stub before "interp.evalFile("test.tcl");" to get the output of the execution to a text file stdout = System.out; stderr = System.err; FileOutputStream iosFile = new FileOutputStream("output.txt"); PrintStream ps = new PrintStream(iosFile); System.setOut(ps); System.setErr(ps); thanks ! going, going, ... gone. Mo DeJong <mo...@mo...> wrote: rohit wrote: > good morning, > > am trying to execute a simple tcl script from a java stub. below is > the java stub and the tcl script. > > i am able to execute the script. however, i need to get the results of > the tcl script execution into a output stream / buffer in the calling > java stub. i am not able to figure how this is done. please help ! > > any pointers/suggestions will be highly appreciated > > java stub : > Interp interp = new Interp(); > > try { > interp.evalFile("test.tcl"); > System.out.println("running tcl done."); > } > catch (TclException ex) { > // some exception handling > } > } > finally { > interp.dispose(); > } > > test.tcl contents : > set a 3 > set b 4 > set message "c = sqrt($a*$a+$b*$b) = [expr sqrt($a*$a+$b*$b)]" > puts $message > Hello Rohit Folks keep asking for this sort of functionality in Jacl, so I went ahead and created a patch to make this much easier. What I did was make the tcl.lang.StdChannel class public and add the methods setIn, setOut, and setErr. These work like the same methods in the Java System class except that the streams will store only data written to stdout or stderr from Tcl. I also updated the extras/GuiShell/GuiShell.java example so that it works with swing under JDK 1.4 and makes use of the new methods in the StdChannel class to implement the kind of redirection you want to do. I think a working example shows exactly what is needed. You can apply this patch to the CVS or just grab the CVS tree fresh. Another approach you could use, which is a lot more simple would be to overload the puts command and then save the results in a variable. Your script could then set the interp result at the end to be the value of this variable. you could also just set the interp result directly, instead of worrying about using puts, but it depends on what you are wanting to do. I hope that thelps Mo DeJong 2007-10-01 Mo DeJong * extras/GuiShell/GuiShell.java: Reimplement GuiShell example so that it uses standard swing package names and makes use of new StdChannel.setOut() and StdChannel.setErr() APIs to redirect output. The GuiShell example now exists in the global package instead of having to live in the tcl.lang package. * extras/GuiShell/README: * extras/GuiShell/swingempty.jar: Removed. * src/jacl/tcl/lang/StdChannel.java (setIn, setOut, setErr): Add new methods used to set the stdin, stdout, and stderr streams used by Jacl. This is more precise than just resetting the streams used by Java since it provides a way for an application to read just the results of Tcl's puts command. Index: extras/GuiShell/GuiShell.java =================================================================== RCS file: /cvsroot/tcljava/tcljava/extras/GuiShell/GuiShell.java,v retrieving revision 1.2 diff -u -r1.2 GuiShell.java --- extras/GuiShell/GuiShell.java 13 Mar 2003 22:28:10 -0000 1.2 +++ extras/GuiShell/GuiShell.java 1 Oct 2007 21:41:29 -0000 @@ -1,40 +1,17 @@ -package tcl.lang; +import tcl.lang.*; -// We can not compile outside of the tcl.lang package -// the perms inside jacl need to be fixed before this will work -//import tcl.lang.*; +import java.io.*; import java.awt.*; import java.awt.event.*; -import java.io.*; - -// we need to incluse swingempty.jar in CLASSPATH so we -// can compile with swing 1.0 and 1.1 - -import com.sun.java.swing.*; -import com.sun.java.swing.text.*; -import com.sun.java.swing.event.*; - import javax.swing.*; import javax.swing.text.*; import javax.swing.event.*; - public class GuiShell { - private static String pre_swing; - - static { - Class c = UIManager.class; - String c_name = c.getName(); - - pre_swing = "com.sun.java.swing"; - if (c_name.startsWith(pre_swing)) { - pre_swing = "javax.swing"; - } - - } + private static String pre_swing = "javax.swing"; public GuiShell() { @@ -54,7 +31,7 @@ - frame = new JFrame("Main"); + frame = new JFrame("GuiShell"); frame.setSize(500,350); frame.setLocation(100,100); frame.addWindowListener(closer); @@ -69,7 +46,6 @@ append("% "); - JScrollPane scroller = new JScrollPane(edit,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); @@ -85,29 +61,23 @@ public void setupInterp() { try { - interp.setVar("argv0", "tcl.lang.Shell", TCL.GLOBAL_ONLY); - interp.setVar("tcl_interactive", "1", TCL.GLOBAL_ONLY); + interp.setVar("argv0", TclString.newInstance("tcl.lang.Shell"), TCL.GLOBAL_ONLY); + interp.setVar("tcl_interactive", TclString.newInstance("1"), TCL.GLOBAL_ONLY); interp.setVar("argv", TclList.newInstance(), TCL.GLOBAL_ONLY); - interp.setVar("argc", "0", TCL.GLOBAL_ONLY); + interp.setVar("argc", TclString.newInstance("0"), TCL.GLOBAL_ONLY); } catch (TclException e) { throw new TclRuntimeError("unexpected TclException: " + e); } - ThreadedTclEventLoop tsr = new ThreadedTclEventLoop(); - Thread t = new Thread(tsr); + Thread t = new Thread(tsr); t.setPriority(Thread.MIN_PRIORITY); t.setDaemon(true); t.start(); - - } - - - public class ThreadedTclEventLoop implements Runnable { public void run() { @@ -121,53 +91,72 @@ } + public void setupStreamReaders() { + try { + // Save original stdout and stderr + _stdout = System.out; + _stderr = System.err; + pout = new PipedOutputStream(); + ps = new PrintStream(pout); + // Connect the PipedInputStream to the PipedOutputStream, + // so that a read on the pin instance will read data + // from the pout instance. - public void setupStreamReaders() { - - try { - stdout = System.out; - stderr = System.err; pin = new PipedInputStream(); - pout = new PipedOutputStream(pin); - ps = new PrintStream(pout); - System.setOut(ps); - System.setErr(ps); + pin.connect(pout); + + // Use Jacl's IO redirection API to send stdout and stderr + // to the PipedOutputStream. + + StdChannel.setOut(ps); + StdChannel.setErr(ps); + } catch (java.io.IOException e) { - e.printStackTrace(stderr); + e.printStackTrace(_stderr); } - ThreadedStreamReader tsr = new ThreadedStreamReader(); - Thread t = new Thread(tsr); + Thread t = new Thread(tsr); //t.setPriority(Thread.MIN_PRIORITY); t.setDaemon(true); t.start(); - } - - + + // This class reads from a PipedInputStream, it is connected + // to a PipedOutputStream that has been set as the output + // channel for both stdout and stderr in the Jacl interpreter. + // The result is that a command like "puts HELLO" will result + // in the string "HELLO" being read by this method. public class ThreadedStreamReader implements Runnable { - + public void run() { + final boolean debug = false; + + if (debug) { + _stderr.println("Entered ThreadedStreamReader.run()"); + } + BufferedReader br = new BufferedReader(new InputStreamReader(pin)); - + String nextline = null; - + while (true) { try { - nextline = br.readLine() + "\n"; - doc.insertString(doc.getLength(), nextline, null); - edit.setCaretPosition(doc.getLength()); - + nextline = br.readLine() + "\n"; + if (debug) { + _stderr.println("readLine() -> \"" + nextline + "\""); + } + doc.insertString(doc.getLength(), nextline, null); + edit.setCaretPosition(doc.getLength()); } catch (IOException e) { - e.printStackTrace(stderr); + e.printStackTrace(_stderr); } catch (BadLocationException e) { - e.printStackTrace(stderr); + e.printStackTrace(_stderr); } } @@ -203,9 +192,11 @@ public void processCommand() { + final boolean debug = false; - //System.out.println("now to process event"); - + if (debug) { + System.out.println("now to process event"); + } if (cmd_buff.length() == 0) { return; @@ -240,15 +231,10 @@ append("command returned bad code: " + code + "\n"); } } - - - //System.out.println("done processing event"); - - //try to read any data still floating around in stdout or stderr - - System.out.flush(); - System.err.flush(); + if (debug) { + System.out.println("done processing event"); + } Thread.yield(); Thread.yield(); @@ -282,47 +268,47 @@ - //append this string into the text widget + // append this string into the text widget + public void append(String str) { try { doc.insertString(doc.getLength(),str,null); + edit.setCaretPosition(doc.getLength()); } catch (BadLocationException e) { throw new RuntimeException(e.toString()); } } - - //delete char from the end of the widget public void removeLastChar() { try { doc.remove(doc.getLength()-1,1); + edit.setCaretPosition(doc.getLength()); } catch (BadLocationException e) { throw new RuntimeException(e.toString()); } } - - - public class Editor extends JEditorPane { - - private final boolean debug = false; + + private static final boolean debug = false; protected void processComponentKeyEvent(KeyEvent e) { - if (debug) { - //System.out.println("processing " + e); + if (false && debug) { + System.out.println("processComponentKeyEvent " + e); } - if (e.getKeyCode() != 0) { - return; //only process key typed commands + // Ignore KEY_PRESSED and KEY_RELEASED, only process KEY_TYPED + // events in this method. + + return; } char c = e.getKeyChar(); @@ -332,7 +318,7 @@ } - //if they pressed Return + // if they pressed Return if (c == KeyEvent.VK_ENTER) { @@ -341,14 +327,14 @@ } cmd_buff.append("\n"); - append("\n"); + //append("\n"); if (isCommandComplete()) { processCommand(); cmd_buff.setLength(0); - + append("% "); } else { @@ -366,18 +352,17 @@ else if (c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_DELETE) { - //letter deleted + // letter deleted if (debug) { System.out.println("letter deleted"); } - //stop deleting at front of this line + // stop deleting at front of this line if (cur_line_chars != 0) { cmd_buff.setLength(cmd_buff.length() - 1); cur_line_chars--; - removeLastChar(); } else { if (debug) { System.out.println("begin of cur_line"); @@ -387,28 +372,18 @@ } else { - //for any other letter - cmd_buff.append(c); cur_line_chars++; - append(String.valueOf(c)); - } - - - /* if (debug) { System.out.println("after event process"); System.out.println("cmd_buff is \"" + cmd_buff + "\""); System.out.println("cmd_buff len is " + cmd_buff.length()); System.out.println("cur_line_chars is " + cur_line_chars); } - */ - edit.setCaretPosition(doc.getLength()); - } } @@ -433,8 +408,8 @@ private transient PipedOutputStream pout = null; private transient PrintStream ps = null; - private transient PrintStream stdout = null; - private transient PrintStream stderr = null; + private transient PrintStream _stdout = null; + private transient PrintStream _stderr = null; private transient Thread messageThread = null; private transient StringBuffer cmd_buff = new StringBuffer(200); Index: extras/GuiShell/README =================================================================== RCS file: /cvsroot/tcljava/tcljava/extras/GuiShell/README,v retrieving revision 1.1 diff -u -r1.1 README --- extras/GuiShell/README 8 May 1999 05:19:00 -0000 1.1 +++ extras/GuiShell/README 1 Oct 2007 21:41:29 -0000 @@ -3,20 +3,11 @@ of the tcl.lang.Shell class that ships with jacl. It is not included in the regular classes because it requires the Swing toolkit to work. -To compile the GuiShell program you will need to make sure the -swingempty.jar file is included on your CLASSPATH. You can then -compile GuiShell.java with swing 1.0 or swing 1.1. You will need -to include the created .class files on your CLASSPATH. Watch out -becasue the GuiShell classes are in the tcl.lang package so -you need to set up the directory structure correctly. The best way -to do this is to use the -d argument to javac. +To compile the GuiShell program, make sure the CLASSPATH is setup +properly and includes the Jacl jar files. Then invoke javac like so: -(build it, also make sure swingall.jar is in your CLASSPATH!) +javac GuiShell.java -setenv CLASSPATH ${CLASSPATH}:swingempty.jar:build -mkdir build -javac -d build GuiShell.java +(and to run it) -(run it) - -java tcl.lang.GuiShell +java GuiShell Index: src/jacl/tcl/lang/StdChannel.java =================================================================== RCS file: /cvsroot/tcljava/tcljava/src/jacl/tcl/lang/StdChannel.java,v retrieving revision 1.19 diff -u -r1.19 StdChannel.java --- src/jacl/tcl/lang/StdChannel.java 8 Mar 2003 03:42:44 -0000 1.19 +++ src/jacl/tcl/lang/StdChannel.java 1 Oct 2007 21:41:30 -0000 @@ -20,8 +20,8 @@ * methods to perform read, write, open, close, etc on system stdio channels. */ -class StdChannel extends Channel { - +public class StdChannel extends Channel { + /** * stdType store which type, of the three below, this StdChannel is. */ @@ -37,6 +37,39 @@ static final int STDERR = 2; /** + * These static variables contain references to the actual + * in, out, and err streams that are read from or written + * to when the "stdin", "stdout", or "stderr" streams + * are read from or written to in Jacl. The user should + * invoke the setIn(), setOut(), and setErr() methods + * in this class to reassign to a specific Java stream. + */ + + static InputStream _in = System.in; + static PrintStream _out = System.out; + static PrintStream _err = System.err; + + /** + * Reassign the static variables that reference the + * in, out, and err streams used by Jacl. The user + * should note that these methods will change the + * underlying Java stream in use for all Jacl + * interpreters in the current process. + */ + + public static void setIn(InputStream in) { + _in = in; + } + + public static void setOut(PrintStream out) { + _out = out; + } + + public static void setErr(PrintStream err) { + _err = err; + } + + /** * Constructor that does nothing. Open() must be called before * any of the subsequent read, write, etc calls can be made. */ @@ -124,13 +157,13 @@ checkWrite(interp); if (stdType == STDERR) { - System.err.print(outData.toString()); + _err.print(outData.toString()); } else { String s = outData.toString(); - System.out.print(s); + _out.print(s); if (buffering == TclIO.BUFF_NONE || (buffering == TclIO.BUFF_LINE && s.endsWith("\n"))) { - System.out.flush(); + _out.flush(); } } } @@ -144,7 +177,7 @@ super.close(); if (stdType == STDOUT) - System.out.flush(); + _out.flush(); } String getChanType() { @@ -152,7 +185,7 @@ } protected InputStream getInputStream() throws IOException { - return System.in; + return _in; } protected OutputStream getOutputStream() throws IOException { ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ tcljava-user mailing list tcl...@li... https://lists.sourceforge.net/lists/listinfo/tcljava-user --------------------------------- Pinpoint customers who are looking for what you sell. |
From: Mo D. <mo...@mo...> - 2007-10-01 21:57:37
|
rohit wrote: > good morning, > > am trying to execute a simple tcl script from a java stub. below is > the java stub and the tcl script. > > i am able to execute the script. however, i need to get the results of > the tcl script execution into a output stream / buffer in the calling > java stub. i am not able to figure how this is done. please help ! > > any pointers/suggestions will be highly appreciated > > java stub : > Interp interp = new Interp(); > > try { > interp.evalFile("test.tcl"); > System.out.println("running tcl done."); > } > catch (TclException ex) { > // some exception handling > } > } > finally { > interp.dispose(); > } > > test.tcl contents : > set a 3 > set b 4 > set message "c = sqrt($a*$a+$b*$b) = [expr sqrt($a*$a+$b*$b)]" > puts $message > Hello Rohit Folks keep asking for this sort of functionality in Jacl, so I went ahead and created a patch to make this much easier. What I did was make the tcl.lang.StdChannel class public and add the methods setIn, setOut, and setErr. These work like the same methods in the Java System class except that the streams will store only data written to stdout or stderr from Tcl. I also updated the extras/GuiShell/GuiShell.java example so that it works with swing under JDK 1.4 and makes use of the new methods in the StdChannel class to implement the kind of redirection you want to do. I think a working example shows exactly what is needed. You can apply this patch to the CVS or just grab the CVS tree fresh. Another approach you could use, which is a lot more simple would be to overload the puts command and then save the results in a variable. Your script could then set the interp result at the end to be the value of this variable. you could also just set the interp result directly, instead of worrying about using puts, but it depends on what you are wanting to do. I hope that thelps Mo DeJong |
From: Horace A. 'K. V. <ha...@ha...> - 2007-10-01 19:37:33
|
to get the retultsd of the puts in the tcl, maybe something like ... interp.getResult().toString(); ...following the eval call? > java stub : > Interp interp = new Interp(); > > try { > interp.evalFile("test.tcl"); System.out.print(interp.getResult().toString()); > System.out.println("running tcl done."); > } > catch (TclException ex) { > // some exception handling > } > } > finally { > interp.dispose(); > } > > test.tcl contents : > set a 3 > set b 4 > set message "c = sqrt($a*$a+$b*$b) = [expr sqrt($a*$a+$b*$b)]" > puts $message > -- Horace ...once known as "Kicker" :-) ================================================================ ...drop by and chat if I'm online http://www.hav.com/chat/ ...or chuckle at a little left hand fingertip torture http://www.hav.com/junk/ After silence, that which comes nearest to expressing the inexpressible is music - Aldous Huxley, "Music at Night", 1931 ... and that which comes nearest to explaining the inexplicable is my insistence on trying to play it - hav '06 :-)) ================================================================ Horace Vallas hav.Software http://www.hav.com/ 4660 Francisco Rd. ha...@ha... Pensacola, Fl. 32504 USA 850-207-7009 Thawte Web Of Trust Notary in Pensacola, Fl. http://www.hav.com/?content=/thawteWOTnotary.htm |
From: mallick c. <mal...@ya...> - 2007-10-01 19:12:40
|
Hi Rohit, When script is executed , each command is executed and the result is stored in the interp , after the execution of last command, the result of be will streamed out. If you want to print where ever you need then use "puts [ yours command ]" which will print output of "your command" on to the prompt.. hope this helps mallick --- tcl...@li... wrote: > Send tcljava-user mailing list submissions to > tcl...@li... > > To subscribe or unsubscribe via the World Wide Web, > visit > > https://lists.sourceforge.net/lists/listinfo/tcljava-user > or, via email, send a message with subject or body > 'help' to > tcl...@li... > > You can reach the person managing the list at > tcl...@li... > > When replying, please edit your Subject line so it > is more specific > than "Re: Contents of tcljava-user digest..." > > > Today's Topics: > > 1. help - how to execute a tcl from java (rohit) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 1 Oct 2007 01:00:16 -0700 (PDT) > From: rohit <roh...@ya...> > Subject: [tcljava-user] help - how to execute a tcl > from java > To: tcl...@li... > Message-ID: > <966...@we...> > Content-Type: text/plain; charset="iso-8859-1" > > good morning, > > am trying to execute a simple tcl script from a java > stub. below is the java stub and the tcl script. > > i am able to execute the script. however, i need to > get the results of the tcl script execution into a > output stream / buffer in the calling java stub. i > am not able to figure how this is done. please help > ! > > any pointers/suggestions will be highly appreciated > > java stub : > Interp interp = new Interp(); > > try { > interp.evalFile("test.tcl"); > System.out.println("running tcl done."); > } > catch (TclException ex) { > // some exception handling > } > } > finally { > interp.dispose(); > } > > test.tcl contents : > set a 3 > set b 4 > set message "c = sqrt($a*$a+$b*$b) = [expr > sqrt($a*$a+$b*$b)]" > puts $message > > going, going, ... gone. > > --------------------------------- > Luggage? GPS? Comic books? > Check out fitting gifts for grads at Yahoo! Search. > -------------- next part -------------- > An HTML attachment was scrubbed... > > ------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > ------------------------------ > > _______________________________________________ > tcljava-user mailing list > tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcljava-user > > > End of tcljava-user Digest, Vol 16, Issue 1 > ******************************************* > ____________________________________________________________________________________ Shape Yahoo! in your own image. Join our Network Research Panel today! http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 |
From: rohit <roh...@ya...> - 2007-10-01 08:00:21
|
good morning, am trying to execute a simple tcl script from a java stub. below is the java stub and the tcl script. i am able to execute the script. however, i need to get the results of the tcl script execution into a output stream / buffer in the calling java stub. i am not able to figure how this is done. please help ! any pointers/suggestions will be highly appreciated java stub : Interp interp = new Interp(); try { interp.evalFile("test.tcl"); System.out.println("running tcl done."); } catch (TclException ex) { // some exception handling } } finally { interp.dispose(); } test.tcl contents : set a 3 set b 4 set message "c = sqrt($a*$a+$b*$b) = [expr sqrt($a*$a+$b*$b)]" puts $message going, going, ... gone. --------------------------------- Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search. |
From: Mo D. <mo...@mo...> - 2007-09-25 20:06:26
|
mallick choppa wrote: > Hi > I want design a concept of Man pages for my new > extended commands in jacl. How can this be done? Any > ideas? > To be honest, I am not sure what you are asking. A good starting approach might be to copy the existing HTML documentation in tcljava (see tcljava/docs/TclJava/contents.html) and create specific HTML pages for each of your commands. That would at least provide a template for your to copy when creating your own man pages. I hope that helps Mo DeJong |
From: Tom P. <tpo...@ny...> - 2007-09-25 19:52:32
|
Aejaks version 0.6 is ready for download. Website: http://aejaks.sourceforge.net/ Download: http://sourceforge.net/project/showfiles.php?group_id=184611 Highlights for 0.6: * New Widgets - from EchopointNG o AbleProperties o ComboBox (includes type-ahead autocomplete) o DirectHtml (arbitrary HTML in a DIV) o ExpandableSection o GroupBox o ProgressBar o Slider o TextFieldEx (includes client-side regexp validation) * New BrowserCommand options: javascript eval, javascript include, print * New Clock and NumberGuess sample apps, contributed by Geoffrey Wu. Note that the Aejaks/Tcl version of NumberGuess is less than one-third the size of the equivalent Echo2/Java version! * Lots of clean-up of the automated object build system. * Misc. bug fixes, documentation updates. Full change list: http://aejaks.sourceforge.net/CHANGES.txt About Aejaks: Aejaks combines the server-side Ajax windowing system Echo2 with the powerful simplicity of the Tcl langauge. The result is a rich development environment in which to develop Ajax-based web applications, often with much less code to write. Aejaks runs on top of a Java Servlet engine, and can make use of any existing Java library. -- Tom Poindexter tpo...@ny... |
From: mallick c. <mal...@ya...> - 2007-09-20 16:55:05
|
Hi I want design a concept of Man pages for my new extended commands in jacl. How can this be done? Any ideas? PS: I have created safe interpreter so cannot do exec. thanks in advance Mallick ____________________________________________________________________________________ Check out the hottest 2008 models today at Yahoo! Autos. http://autos.yahoo.com/new_cars.html |
From: mallick c. <mal...@ya...> - 2007-09-12 07:30:34
|
Hi All, Thanks very much for your replies , I think that will work for my requirement.. mallick --- tcl...@li... wrote: > Send tcljava-user mailing list submissions to > tcl...@li... > > To subscribe or unsubscribe via the World Wide Web, > visit > > https://lists.sourceforge.net/lists/listinfo/tcljava-user > or, via email, send a message with subject or body > 'help' to > tcl...@li... > > You can reach the person managing the list at > tcl...@li... > > When replying, please edit your Subject line so it > is more specific > than "Re: Contents of tcljava-user digest..." > > > Today's Topics: > > 1. Re: Restrict to change global variable value > (Tom Poindexter) > 2. Re: Restrict to change global variable value > (Patrick Finnegan) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 10 Sep 2007 13:36:34 -0600 > From: Tom Poindexter <tpo...@ny...> > Subject: Re: [tcljava-user] Restrict to change > global variable value > To: A list for users of tcljava > <tcl...@li...> > Message-ID: <200...@ny...> > Content-Type: text/plain; charset=us-ascii > > On Mon, Sep 10, 2007 at 08:33:01AM -0700, mallick > choppa wrote: > > > > How can I restrict the changing of global variable > > which was set through programatically while > > initializing the interpreter? > > Any help , i will be very thankful. > > > Traces might work for you, see: > http://wiki.tcl.tk/398 > http://wiki.tcl.tk/1734 (see section 'readonly > trace') > > -- > Tom Poindexter > tpo...@ny... > > > > ------------------------------ > > Message: 2 > Date: Tue, 11 Sep 2007 09:06:35 +0100 > From: "Patrick Finnegan" > <fin...@gm...> > Subject: Re: [tcljava-user] Restrict to change > global variable value > To: "A list for users of tcljava" > <tcl...@li...> > Message-ID: > > <897...@ma...> > Content-Type: text/plain; charset="iso-8859-1" > > Try the OO extension incr. It has been ported to > Jacl. > > "Each of the elements in a class can be declared > "public", "protected" or > "private". Public elements can be accessed by the > class, by derived classes > (other classes that inherit this class), and by > external clients that use > the class. Protected elements can be accessed by the > class, and by derived > classes. Private elements are only accessible in the > class where they are > defined. > > The "public" elements within a class define its > interface to the external > world. Public methods define the operations that can > be used to manipulate > an object. Public variables are recognized as > configuration options by the > "configure" and "cget" methods that are built into > each class. The public > interface says *what* an object will do but not > *how* it will do it. > Protected and private members, along with the bodies > of class methods and > procs, provide the implementation details. > Insulating the application > developer from these details leaves the class > designer free to change them > at any time, without warning, and without affecting > programs that rely on > the class.". > http://wiki.tcl.tk/62 > > On 10/09/2007, mallick choppa <mal...@ya...> > wrote: > > > > Hi > > I have set a global variable in my interpreter. I > have > > extended few commands implementing > tcl.lang.Command, > > in which i access the global variable and and use > the > > value. > > At the same time I have given provision for TCL > > scripts loading through source command. In order > to > > access global variable , we have to specify global > > <variable> in proc.. > > > > Any user can write proc command and load the > script in > > my system, in the proc command user can change the > > value of global variable. Futher all my other > command > > will faile which are using this global variable. > > > > > > How can I restrict the changing of global variable > > which was set through programatically while > > initializing the interpreter? > > Any help , i will be very thankful. > > > > > > regards > > Mallick > > > > > > > > > > > > > ____________________________________________________________________________________ > > Building a website is a piece of cake. Yahoo! > Small Business gives you all > > the tools to get online. > > http://smallbusiness.yahoo.com/webhosting > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio > 2005. > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > _______________________________________________ > > tcljava-user mailing list > > tcl...@li... > > > https://lists.sourceforge.net/lists/listinfo/tcljava-user > > > -------------- next part -------------- > An HTML attachment was scrubbed... > > ------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > ------------------------------ > > _______________________________________________ > tcljava-user mailing list > tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcljava-user > > > End of tcljava-user Digest, Vol 15, Issue 3 > ******************************************* > ____________________________________________________________________________________ Got a little couch potato? Check out fun summer activities for kids. http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz |
From: Patrick F. <fin...@gm...> - 2007-09-11 08:06:35
|
Try the OO extension incr. It has been ported to Jacl. "Each of the elements in a class can be declared "public", "protected" or "private". Public elements can be accessed by the class, by derived classes (other classes that inherit this class), and by external clients that use the class. Protected elements can be accessed by the class, and by derived classes. Private elements are only accessible in the class where they are defined. The "public" elements within a class define its interface to the external world. Public methods define the operations that can be used to manipulate an object. Public variables are recognized as configuration options by the "configure" and "cget" methods that are built into each class. The public interface says *what* an object will do but not *how* it will do it. Protected and private members, along with the bodies of class methods and procs, provide the implementation details. Insulating the application developer from these details leaves the class designer free to change them at any time, without warning, and without affecting programs that rely on the class.". http://wiki.tcl.tk/62 On 10/09/2007, mallick choppa <mal...@ya...> wrote: > > Hi > I have set a global variable in my interpreter. I have > extended few commands implementing tcl.lang.Command, > in which i access the global variable and and use the > value. > At the same time I have given provision for TCL > scripts loading through source command. In order to > access global variable , we have to specify global > <variable> in proc.. > > Any user can write proc command and load the script in > my system, in the proc command user can change the > value of global variable. Futher all my other command > will faile which are using this global variable. > > > How can I restrict the changing of global variable > which was set through programatically while > initializing the interpreter? > Any help , i will be very thankful. > > > regards > Mallick > > > > > > ____________________________________________________________________________________ > Building a website is a piece of cake. Yahoo! Small Business gives you all > the tools to get online. > http://smallbusiness.yahoo.com/webhosting > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > tcljava-user mailing list > tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcljava-user > |
From: Tom P. <tpo...@ny...> - 2007-09-10 19:36:38
|
On Mon, Sep 10, 2007 at 08:33:01AM -0700, mallick choppa wrote: > > How can I restrict the changing of global variable > which was set through programatically while > initializing the interpreter? > Any help , i will be very thankful. Traces might work for you, see: http://wiki.tcl.tk/398 http://wiki.tcl.tk/1734 (see section 'readonly trace') -- Tom Poindexter tpo...@ny... |
From: mallick c. <mal...@ya...> - 2007-09-10 15:33:06
|
Hi I have set a global variable in my interpreter. I have extended few commands implementing tcl.lang.Command, in which i access the global variable and and use the value. At the same time I have given provision for TCL scripts loading through source command. In order to access global variable , we have to specify global <variable> in proc.. Any user can write proc command and load the script in my system, in the proc command user can change the value of global variable. Futher all my other command will faile which are using this global variable. How can I restrict the changing of global variable which was set through programatically while initializing the interpreter? Any help , i will be very thankful. regards Mallick ____________________________________________________________________________________ Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online. http://smallbusiness.yahoo.com/webhosting |
From: Patrick F. <fin...@gm...> - 2007-09-07 06:50:53
|
I had a look at some of the threads on the comp.lang.tcl newsgroup and it seems that "catch" destroys the error location information when the stack unwinds http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/4dd1c0a1eba12999/840020cf40ca2f9f?lnk=gst&q=%2B%22error%22%2B%22catch%22&rnum=6#840020cf40ca2f9f The recommendation is to throw an error after the catch to trigger the stack trace but I find that in Jacl "return -code error $r" does not generate the error information. E.G if { [ catch { $AdminConfig yabba } r ] == 0 } { set donothing true } else { return -code error $r } gives............... WASX7017E: Exception received while running file "C:\home\patrick\eclipse\WASAdminSBV\WSAdmin\WAS6.1\JACL\installCluster.tcl"; exception information: com.ibm.bsf.BSFException: error while eval'ing Jacl expression: no accessible method "yabba" in class com.ibm.ws.scripting.AdminConfigClient invoked from within "::installCluster::installCluster $propertiesFile " I found that one way to trigger a full error stack is to insert an invalid command option. if { [ catch { $AdminConfig yabba } r ] == 0 } { set donothing true } else { "return -code error $r $::errorInfo $::errorCode" } gives.................... WASX7017E: Exception received while running file "C:\home\patrick\eclipse\WASAdminSBV\WSAdmin\WAS6.1\JACL\installCluster.tcl"; exception information: com.ibm.bsf.BSFException: error while eval'ing Jacl expression: bad option "no accessible method "yabba" in class com.ibm.ws.scripting.AdminConfigClient": must be -code, -errorcode, or -errorinfo while executing "return -code error $r $::errorInfo $::errorCode" ("if" else script line 5) invoked from within "if { [ catch { $AdminConfig yabba } r ] == 0 } { set donothing true } else { #return -code error $r re..." (procedure "::installCluster::installCluster" line 28) invoked from within "::installCluster::installCluster $propertiesFile " Is there a better way to preserve the error location information when using nested catches? |
From: Patrick F. <fin...@gm...> - 2007-08-23 14:06:45
|
I extracted the Tcl log package and auto loaded it into Jacl. I wrote it up for the WebSphere guys: See: http://www.websphereconsultant.com/WSAdmin/docs/logPackage.html Are there any other Tcl 8.0 util type packages available for Jacl? How far off Tcl 8.1.14 is Jacl 1.4? |
From: Johann T. <jo...@da...> - 2007-08-22 20:07:48
|
> Shibu Cyriac wrote: >> Hi All, >> I need to use a custom classloader as the default classloader in my >> TclBlend application. > > I don't think there is an easy way to do that... > You don't really create a class loader and then tell the system to > use it instead of the default one. > (snip) If you've got your own thread to work with, telling the system you're going to use a new class loader is fairly simple: public class MyThread extends Thread { public MyThread () { this.setContextClassLoader ( new MyClassLoader () ); } } I don't use TclBlend, but this works well for a Jacl environment. Mind you mixing and matching ClassLoaders is very dangerous... For example, a String object that is loaded by the system class loader is NOT of the same class as a String loaded by your own class loader. This concept may seem obvious, but debugging can be quite painful! So as Mo suggested, setting the class loader before anything has really happened in your application is necessary if you share objects between threads, or if you're in a single-threaded environment. For example, rather than executing your app with "java x.y.z.MyClass", add a main () method to your MyClassLoader and execute the app with "java MyClassLoader". The main () method of MyClassLoader.java might look something like: import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; ... String my_class_name = "x.y.z.MyClass"; String [] my_args = new String [ 0 ]; try { // Create our own class loader. MyClassLoader my_class_loader = new MyClassLoader ( ClassLoader.getSystemClassLoader () ); // Load in some class "x.y.z.MyClass", so that we can // execute its main () method. Class cl = my_class_loader.loadClass ( my_class_name ); // Find the main () method of MyClass. A bit sloppy... Method [] methods = cl.getMethods (); Method mmain = null; for ( int m = 0; m < methods.length; m ++ ) { if ( methods [ m ].getName ().equals ( "main" ) ) { mmain = methods [ m ]; break; } } if ( mmain == null ) { throw new NoSuchMethodException ( "main" ); } // Start up the application: MyClass.main ( args ). mmain.invoke ( null, (Object) my_args ); } catch ( ClassNotFoundException e ) { e.printStackTrace (); } catch ( NoSuchMethodException e ) { e.printStackTrace (); } catch ( IllegalAccessException e ) { e.printStackTrace (); } catch ( InvocationTargetException e ) { e.printStackTrace (); } This forces all classes that will be used by the application to be loaded through the MyClassLoader, and might save you some time trying to figure out why a String is not a String (a subject better left to philosophers anyway). Hope this helps, Johann Tienhaara |
From: Tom P. <tpo...@ny...> - 2007-08-22 16:23:20
|
There is also: http://www.axiomsol.com/pro_serv/compiler.php Looks like C only, no C++. Haven't tried it myself. Compiles C to bytecodes. Brian - thanks for the pointer to NestedVm. There was a research project several years ago called 'gccjvm'. It was a GCC backend to product java bytecodes. No code online anymore, but the author's dissertation is available at: http://www.montgomerie.net/tEmPlate.pl/downloads/gccjvm/index.html -- Tom Poindexter tpo...@ny... |
From: Brian T. <bri...@gm...> - 2007-08-22 10:53:27
|
On 8/22/07, Patrick Finnegan <fin...@gm...> wrote: > > Has anyone used a tool like "http://www.jazillian.com/" to convert C > to Java? Any reliable free tools out there? > I once played around with NestedVm (http://nestedvm.ibex.org/). Here's a post I made about it a few months back: http://groups.google.com/group/vlerq/browse_frm/thread/7561ea7acfba5e33/# This tool doesn't convert to java, but to java bytecodes. It works with any gcc supported language. At http://www.zentus.com/sqlitejdbc/, sqlite has been compiled to java bytecodes. Brian |
From: Patrick F. <fin...@gm...> - 2007-08-22 10:01:17
|
Has anyone used a tool like "http://www.jazillian.com/" to convert C to Java? Any reliable free tools out there? |
From: Mo D. <mo...@mo...> - 2007-08-22 02:24:13
|
Shibu Cyriac wrote: > Hi All, > I need to use a custom classloader as the default classloader in my > TclBlend application. > Is there any way ought to do that? I don't think there is an easy way to do that. The "default" class loader is typically defined by the JVM. If you want to use a custom one, then you create it and load classes with it. You don't really create a class loader and then tell the system to use it instead of the default one. Classloaders are more of a bottom up approach, where the one you define defers to the system ones when it can't find a class. It is not the case that the system class loaders defer to the custom class loader when a class can't be found. I hope that helps Mo DeJong |
From: Kristoffer L. <se...@fi...> - 2007-08-21 11:19:21
|
On 21 Aug 2007, at 13:24, Patrick Finnegan wrote: > > Anybody in the group working on this? > > http://blogs.sun.com/blue/entry/using_wadm_in_sjswebserver_7 That would make an excellent use case pitch for Tcl on the whole. Must remember it when marketing the language. / http://www.fishpool.com/~setok/ |
From: rahul <ra...@Su...> - 2007-08-21 10:58:19
|
That is my blog :) [Patrick Finnegan:] | Anybody in the group working on this? | | http://blogs.sun.com/blue/entry/using_wadm_in_sjswebserver_7 | ------------------------------------------------------------------------- | This SF.net email is sponsored by: Splunk Inc. | Still grepping through log files to find problems? Stop. | Now Search log events and configuration files using AJAX and a browser. | Download your FREE copy of Splunk now >> http://get.splunk.com/ | _______________________________________________ | tcljava-user mailing list | tcl...@li... | https://lists.sourceforge.net/lists/listinfo/tcljava-user ---~*~--- rahul -- 1. e4 _ |
From: Patrick F. <fin...@gm...> - 2007-08-21 10:56:35
|
Anybody in the group working on this? http://blogs.sun.com/blue/entry/using_wadm_in_sjswebserver_7 |
From: Shibu C. <shi...@ya...> - 2007-08-16 06:14:08
|
Hi All,=0AI need to use a custom classloader as the default classloader in = my TclBlend application.=0AIs there any way ought to do that?=0A=0ACan anyo= ne give me some pointers how to do it....=0AThanks in advance.=0A=0ARegards= ,=0AShibu Cyriac=0A=0A=0A=0A=0A =0A__________________________________= __________________________________________________=0ATake the Internet to G= o: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. = =0Ahttp://mobile.yahoo.com/go?refer=3D1GNXIC |
From: Patrick F. <fin...@gm...> - 2007-08-07 08:39:24
|
On 06/08/07, Mo DeJong <mo...@mo...> wrote: > > Patrick Finnegan wrote: > > > Would you be interested in writing up some patches and documentation > for this kind of functionality in 1.4? Adding to the auto_path should > work as long as a pkgIndex.tcl is found, see the logic in init.tcl > to see how this works. It would also be very nice to be able to place > a pkgIndex.tcl file in the root of a .jar file bundle and only have > to add the .jar to the CLASSPATH or env(TCL_CLASSPATH). > > Mo DeJong OK. Will look into it. |
From: Mo D. <mo...@mo...> - 2007-08-06 20:04:25
|
Patrick Finnegan wrote: > > Just wondering if "package require" works with resource and libraries > packed in jar files. > > e.g. something like. > > C:\Tcl\lib>jar -cvf tcllib1_9.jar tcllib1.9 > > set CLASSPATH=%CLASSPATH%;C:/Tcl/lib/tcllib1_9.jar > > java -classpath %CLASSPATH% tcl.lang.Shell > > % lappend auto_path resource:/tcllib1.9 > resource:/tcl/lang/library resource:/proclib resource:/tcllib1.9 > % package require term > can't find package term > % package require log > can't find package log > Would you be interested in writing up some patches and documentation for this kind of functionality in 1.4? Adding to the auto_path should work as long as a pkgIndex.tcl is found, see the logic in init.tcl to see how this works. It would also be very nice to be able to place a pkgIndex.tcl file in the root of a .jar file bundle and only have to add the .jar to the CLASSPATH or env(TCL_CLASSPATH). Mo DeJong |