[tcljava-user] Re: another question...
by Shawn Boyce other posts by this author
Jan 14 2002 11:04PM messages near this date
Re: [tcljava-user] javap
|
[tcljava-user] question on TCL BLEND 1.26 on Windows 2K
TAZ0789@[...].com wrote:
> hi shawn,
>
> i took your advice and reduce the program to the basics and it works perfect... attached
is the java file... i still have a one question...
>
Great. So your problem is solved.
>
> 1. how can i redirect the standard out and err? i.e. when i issue command "puts hello", i w
ant to redirect the output to the jtextarea, rather than to the console.
>
The only way I know how to do this is to override the standard Tcl
"puts" command with your own.
Your command would write to your jtextarea instead of stdout. I've
attached an example change
of the PutsCmd.java code to do this.
You could also do this completely in Tcl as well.
Something like:
rename puts real_puts
proc puts { args } {
## check args
## if no channel specified, write to my jtextarea using my TestIO object
## testIO writeOutput "args text'"
## else invoke the 'real_puts' command to write to the channel
## real_puts $args
}
You may also want to see the demos/pyramidpkg/AppletConsole.java
to see an example of putting an interpreter in a window. It does not
do the puts redirect that you want though.
>
> please help, thanks...
>
> angela =)
>
> In a message dated Fri, 11 Jan 2002 8:48:11 AM Eastern Standard Time, Shawn Boyce <shawn@[
...].com> writes:
>
> >Can you reduce your program to the basics of the just your JFrame and
> >the Interp
> >call and try it? If you still have trouble, attach the simplified file.
> >
> >Which JDK are you using? Which version of Jacl?
> >
> >TAZ0789@[...].com wrote:
> >
> >>hi shawn,
> >>
> >>thank you for your prompt reply... my main.java is a jframe and it
> >>contains main() which instantiates and calls outputpanel.java.
> >> outputpanel.java contains the jtextarea, which becomes the
> >>interactive jacl shell for my application. for some reason the jframe
> >>from main.java did not display. so i put println statements before
> >>and after the Interp interp = new Interp() call to figure out that
> >>this is where the problem is. i commented out the Interp interp = new
> >>Interp() call and the jframe shows up again. do you have any idea why
> >>this is happening? please help... thanks...
> >>
> >>angela =)
> >>
> >>In a message dated 1/10/2002 6:36:39 PM Pacific Standard Time,
> >>shawn@[...].com writes:
> >>
> >>
> >>>Subj:Re: [tcljava-user] embedding jacl in jtextarea
> >>>Date:1/10/2002 6:36:39 PM Pacific Standard Time
> >>>From: shawn@[...].com (Shawn Boyce)
> >>>Sender: tcljava-user-admin@[...].net
> >>>To: tcljava-user@[...].net
> >>>
> >>>
> >>>
> >>>
> >>>Where exactly does it freeze? The call to Interp looks fine.
> >>>What are you trying to do with the setVar calls?
> >>>
> >>>You do not have to use threads with Interp.
> >>>If only a single thread is using the interpreter, you
> >>>can just do interp.eval() instead of using the Notifier.
> >>>
> >>>TAZ0789@[...].com wrote:
> >>>
> >>>>the problem i'm facing now is that my application will freeze at the
> >>>>
> >>>time where Interp interp = new Interp(); is called. do you have any
> >>>idea why? also, is it mandatory to use threads? below are some parts
> >>>of my code, please help... thanks...
> >>>
> >>>>(outputpanel.java does not contain main())
> >>>>
> >>>>public outputpanel()
> >>>>{
> >>>> outputTextArea = new outputTextArea();
> >>>> createJaclShell();
> >>>>}
> >>>>
> >>>>private void createJaclShell()
> >>>>{
> >>>> clear();
> >>>> output("Jacl shell started...\n");
> >>>> output("% ");
> >>>> Interp interp = new Interp();
> >>>> TclObject argv = TclList.newInstance();
> >>>> argv.preserve();
> >>>> try
> >>>> {
> >>>> int i = 0;
> >>>>
> >>>> interp.setVar("argv0", "tcl.lang.Shell", TCL.GLOBAL_ONLY);
> >>>> interp.setVar("tcl_interactive", "1", TCL.GLOBAL_ONLY);
> >>>> }
> >>>> catch (TclException e)
> >>>> {
> >>>> throw new TclRuntimeError("unexpected TclException: " + e);
> >>>> }
> >>>>}
> >>>>
> >>>>//in keylistener when user hitted enter//
> >>>>
> >>>>//send input to jacl
> >>>>ArribaJaclEvent evt = new ArribaJaclEvent(interp, input);
> >>>>interp.getNotifier().queueEvent(evt, TCL.QUEUE_TAIL);
> >>>>evt.sync();
> >>>>if(evt.evalResult != null)
> >>>>{
> >>>> //output to jtextarea
> >>>> String s = evt.evalResult.toString();
> >>>> if(s.length() > 0)
> >>>> {
> >>>> output(s, "Jacl");
> >>>> }
> >>>>}
> >>>>else
> >>>>{
> >>>> TclException e = evt.evalException;
> >>>> int code = e.getCompletionCode();
> >>>> check_code:
> >>>> {
> >>>> if (code == TCL.RETURN)
> >>>> {
> >>>> code = interp.updateReturnInfo();
> >>>> if (code == TCL.OK)
> >>>> {
> >>>> break check_code;
> >>>> }
> >>>> }
> >>>>
> >>>> switch (code)
> >>>> {
> >>>> case TCL.ERROR:
> >>>> output(interp.getResult().toString());
> >>>> break;
> >>>>
> >>>> case TCL.BREAK:
> >>>> output("invoked \"break\" outside of a loop");
> >>>> break;
> >>>>
> >>>> case TCL.CONTINUE:
> >>>> output("invoked \"continue\" outside of a loop");
> >>>> break;
> >>>>
> >>>> default:
> >>>> output("command returned bad code: " + code);
> >>>> }
> >>>> }
> >>>>}
> >>>>
> >>>>
> >>>>angela =)
> >>>>
> >>>>
> >>>>_______________________________________________
> >>>>tcljava-user mailing list
> >>>>tcljava-user@[...].net
> >>>>https://lists.sourceforge.net/lists/listinfo/tcljava-user
> >>>>
> >>>>
> >>>--
> >>>-Shawn
> >>>
> >>>
> >>>
> >>>
> >>>_______________________________________________
> >>>tcljava-user mailing list
> >>>tcljava-user@[...].net
> >>>https://lists.sourceforge.net/lists/listinfo/tcljava-user
> >>>
> >>>
> >>>----------------------- Headers --------------------------------
> >>>Return-Path: <tcljava-user-admin@[...].net>
> >>>Received: from rly-yc01.mx.aol.com (rly-yc01.mail.aol.com
> >>>[172.18.149.33]) by air-yc05.mail.aol.com (v82.22) with ESMTP id
> >>>MAILINYC52-0110213639; Thu, 10 Jan 2002 21:36:39 -0500
> >>>Received: from usw-sf-list1.sourceforge.net
> >>>(usw-sf-fw2.sourceforge.net [216.136.171.252]) by rly-yc01.mx.aol.com
> >>>(v83.18) with ESMTP id MAILRELAYINYC16-0110213613; Thu, 10 Jan 2002
> >>>21:36:13 -0500
> >>>Received: from localhost ([127.0.0.1] helo=usw-sf-list1.sourceforge.net)
> >>> by usw-sf-list1.sourceforge.net with esmtp (Exim 3.31-VA-mm2 #1
> >>>(Debian))
> >>> id 16OrY2-000571-00; Thu, 10 Jan 2002 18:36:02 -0800
> >>>Received: from server11.safepages.com ([216.127.146.25])
> >>> by usw-sf-list1.sourceforge.net with esmtp (Exim 3.31-VA-mm2 #1
> >>>(Debian))
> >>> id 16OrXV-0004y2-00
> >>> for <tcljava-user@[...].net>; Thu, 10 Jan 2002
> >>>18:35:29 -0800
> >>>Received: from qcominc.com (10-024.022.popsite.net [64.24.47.24])
> >>> by server11.safepages.com (Postfix) with ESMTP id 6ABBA14F75E
> >>> for <tcljava-user@[...].net>; Fri, 11 Jan 2002
> >>>02:35:02 +0000 (GMT)
> >>>Message-ID: <3C3E4F4F.7070103@[...].com>
> >>>From: Shawn Boyce <shawn@[...].com>
> >>>Organization: QCOM Inc.
> >>>User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4)
> >>>Gecko/20011019 Netscape6/6.2
> >>>X-Accept-Language: en-us
> >>>MIME-Version: 1.0
> >>>To: tcljava-user@[...].net
> >>>Subject: Re: [tcljava-user] embedding jacl in jtextarea
> >>>References: <62.191ccc9a.296f9e0b@[...].com>
> >>>Content-Type: text/plain; charset=us-ascii; format=flowed
> >>>Content-Transfer-Encoding: 7bit
> >>>Sender: tcljava-user-admin@[...].net
> >>>Errors-To: tcljava-user-admin@[...].net
> >>>X-BeenThere: tcljava-user@[...].net
> >>>X-Mailman-Version: 2.0.5
> >>>Precedence: bulk
> >>>List-Help:
> >>><mailto:tcljava-user-request@lists.sourceforge.net?subject=help>
> >>>List-Post: <mailto:tcljava-user@[...].net>
> >>>List-Subscribe:
> >>><https://lists.sourceforge.net/lists/listinfo/tcljava-user>,
> >>> <mailto:tcljava-user-request@lists.sourceforge.net?subject=subscribe>
> >>>List-Id: A list for users of tcljava
> >>><tcljava-user.lists.sourceforge.net>
> >>>List-Unsubscribe:
> >>><https://lists.sourceforge.net/lists/listinfo/tcljava-user>,
> >>> <mailto:tcljava-user-request@lists.sourceforge.net?subject=unsubscribe>
> >>>
> >>>List-Archive:
> >>><http://www.geocrawler.com/redir-sf.php3?list=tcljava-user>
> >>>X-Original-Date: Thu, 10 Jan 2002 21:34:55 -0500
> >>>Date: Thu, 10 Jan 2002 21:34:55 -0500
> >>>
> >>>
> >>
> >--
> >-Shawn
> >
> >
> >
> >
> >_______________________________________________
> >tcljava-user mailing list
> >tcljava-user@[...].net
> >https://lists.sourceforge.net/lists/listinfo/tcljava-user
> >
>
--
-Shawn
Attachments:
MyPutsCmd.java
TestIO.java
|