For Programmers: Free Programming Magazines  


Home > Archive > Tcl > June 2007 > very basic question please help me









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author very basic question please help me
Pavan

2007-06-24, 8:11 am

Hi Iam very beginner of tcl. I have seen some tutorials on tcl but I
found something is missing

I have a simple my_first_tcl_script.tcl file with contents:

puts "This is my first tcl script"

When I run in windows using

C:\path\wish82.exe my_first_tcl_script.tcl, Iam getting a tcl window
(with no tool bar).

My intention is that I need to see the display "This is my first tcl
script", but this is not coming. Why? Do I need to include any
header(like in c++ we include <iostream> for I/O)?

My tcl version is 8.2.3 and OS is Windows2000.

Jeff Godfrey

2007-06-24, 8:11 am


"Pavan" <pavan734@gmail.com> wrote in message
news:1182601396.685853.300210@o11g2000prd.googlegroups.com...
> Hi Iam very beginner of tcl. I have seen some tutorials on tcl but I
> found something is missing
>
> I have a simple my_first_tcl_script.tcl file with contents:
>
> puts "This is my first tcl script"
>
> When I run in windows using
>
> C:\path\wish82.exe my_first_tcl_script.tcl, Iam getting a tcl
> window
> (with no tool bar).
>
> My intention is that I need to see the display "This is my first tcl
> script", but this is not coming. Why? Do I need to include any
> header(like in c++ we include <iostream> for I/O)?
>
> My tcl version is 8.2.3 and OS is Windows2000.


Hi Pavan,

The [puts] command writes to the stdout channel. Under Windows, when
you run the wish executable, you only get a GUI window, which doesn't
contain the necessary machinery to display the stdout (or stderr)
channel. The wish executable contains both Tcl and Tk, and is
designed for running GUI-based applications. You have a few choices.

If your program is entirely command-line based (that is, contains no
GUI components), instead of running it with "wish.exe", you can run it
with tclsh.exe. That should display the output of your original [puts]
right at the command line. If, on the other hand, your application
does (or will) contain GUI components, you do indeed need to run it
with wish.exe, but in that case you'll want to add the following code
to the top of your program:

console show

That'll open a console window (along with the existing GUI window),
which will display anything you write to the stdout or stderr
channels.

Hope that helps.

Jeff


Pavan

2007-06-24, 8:11 am


Pavan wrote:
> Hi Iam very beginner of tcl. I have seen some tutorials on tcl but I
> found something is missing
>
> I have a simple my_first_tcl_script.tcl file with contents:
>
> puts "This is my first tcl script"
>
> When I run in windows using
>
> C:\path\wish82.exe my_first_tcl_script.tcl, Iam getting a tcl window
> (with no tool bar).
>
> My intention is that I need to see the display "This is my first tcl
> script", but this is not coming. Why? Do I need to include any
> header(like in c++ we include <iostream> for I/O)?
>
> My tcl version is 8.2.3 and OS is Windows2000.


With respect to my above question, The linux script works which looks
like

#!/bin/sh
# the next line restarts using tclsh \
exec tclsh $0 ${1+"$@"}

puts "This is my first tcl script"

and I run this in linux using ./my_file_name.sh

Pavan

2007-06-24, 8:11 am

On Jun 23, 5:37 pm, "Jeff Godfrey" <jeff_godf...@pobox.com> wrote:
> "Pavan" <pavan...@gmail.com> wrote in message
>
> news:1182601396.685853.300210@o11g2000prd.googlegroups.com...
>
>
>
>
>
>
>
>
>
>
>
>
> Hi Pavan,
>
> The [puts] command writes to the stdout channel. Under Windows, when
> you run the wish executable, you only get a GUI window, which doesn't
> contain the necessary machinery to display the stdout (or stderr)
> channel. The wish executable contains both Tcl and Tk, and is
> designed for running GUI-based applications. You have a few choices.
>
> If your program is entirely command-line based (that is, contains no
> GUI components), instead of running it with "wish.exe", you can run it
> with tclsh.exe. That should display the output of your original [puts]
> right at the command line. If, on the other hand, your application
> does (or will) contain GUI components, you do indeed need to run it
> with wish.exe, but in that case you'll want to add the following code
> to the top of your program:
>
> console show
>
> That'll open a console window (along with the existing GUI window),
> which will display anything you write to the stdout or stderr
> channels.
>
> Hope that helps.
>
> Jeff- Hide quoted text -
>
> - Show quoted text -


Dear Jeff thank you. Iam seeing the output with tclsh.exe

Darren New

2007-06-25, 10:10 pm

Larry W. Virden wrote:
> So Windows is incapable of displaying stdout or stderr in this mode?


Well, you can [console show], which brings up a GUI window. Or you can
create a console with stdout and stderr bound to it, but then that
brings up one of those black windows to show the output in. You need a C
hack to do that, tho.

> Or is this "simply" a Tk design decision? If the latter, I would
> think that a better solution would be to pop up a window managing
> stdout/stderr/stdin when they occur (but not to bother until something
> attempts to access them).


So redefine puts and gets to pop up the console. :-)

--
Darren New / San Diego, CA, USA (PST)
I bet exercise equipment would be a lot more
expensive if we had evolved from starfish.
suchenwi

2007-06-27, 7:12 pm

On 23 Jun., 14:40, Pavan <pavan...@gmail.com> wrote:
> With respect to my above question, The linux script works which looks
> like
>
> #!/bin/sh
> # the next line restarts using tclsh \
> exec tclsh $0 ${1+"$@"}
>
> puts "This is my first tcl script"
>

The first three lines are old lore. In modern days it is most often
sufficient (on Linux, Solaris, Cygwin) to start a Tcl script with the
single line

#!/usr/bin/env tclsh

And if you need Tk, just say it in a second line: "package require
Tk" :^)

Ron Fox

2007-06-28, 7:12 pm

Actually, my suggestion is to get ActiveTcl,
www.activestate.com it's free, and then use
tkcon as your tcl/wish shell. It handles all this
nasty windows garbage with stdout/stdin for you.


Pavan wrote:
> Hi Iam very beginner of tcl. I have seen some tutorials on tcl but I
> found something is missing
>
> I have a simple my_first_tcl_script.tcl file with contents:
>
> puts "This is my first tcl script"
>
> When I run in windows using
>
> C:\path\wish82.exe my_first_tcl_script.tcl, Iam getting a tcl window
> (with no tool bar).
>
> My intention is that I need to see the display "This is my first tcl
> script", but this is not coming. Why? Do I need to include any
> header(like in c++ we include <iostream> for I/O)?
>
> My tcl version is 8.2.3 and OS is Windows2000.
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com