Re: Is there a way to make 'wish' read standard input?



"tclin1998@xxxxxxxxx" <tclin1998@xxxxxxxxx> wrote in
news:1164716759.266593.109720@xxxxxxxxxxxxxxxxxxxxxxxxxxx:

Just to make my question more clear.

The following is a very simple script:
### tt.tcl begin
set a 123
puts $a
### end

On Linux console, I type in
wish tt.tcl
I'll see a window pop up, and the console shows

northstar:/tmp% wish tt.tcl
123
_

However,
I could not get the command prompt % in the console.
Is there a way to get tcl command prompt % in the above scenario ?
Thanks!

-Todd


Assuming a UNIX-ish environment, where you start your script in a shell
window, as you illustrate, you can get a console attached to stdin/stdout
by including in your source file:

package require Tclx;
after 500 {after idle {commandloop -async -interactive on}}

(We really, really wanted absolutely everything else to run
first ahead of this, so we used nested [after]s.)

On a project at a previous employer we had a standard argument parser
that filtered out and dealt with common arguments (standard logging,
etc.), used in all our applications. Among the standard arguments it
accepted was one to start an interactive console in just this way. I
was probably its biggest user because my colleagues didn't really
understand geometry management, so I was the one who had to fix their
resize behavior. Having an interactive console through which I could
introspect the widgets and play with their attributes helped immensely.

In that project the console did not present full interactive behavior,
that is, commands could not be abbreviated (arguments and subcommands
could), and [unknown] did not, as a last resort, attempt to use exec. I
vaguely recall having investigating and discovered that someone had coded
our standard startup to turn tcl_interactive off, which would account for
that behavior. I've never tested commandloop in a wish interpreter that
allowed tcl_interactive to default.
--
Rich Wurth / rwurth@xxxxxxx / Rumson, NJ USA

.



Relevant Pages

  • Re: Is there a way to make wish read standard input?
    ... I'll see a window pop up, and the console shows ... I could not get the command prompt % in the console. ... where you start your script in a shell ... On a project at a previous employer we had a standard argument parser ...
    (comp.lang.tcl)
  • Re: Restart after windows update fails
    ... Boot to the console and press enter when asked for the password. ... Try system restore from command prompt. ... some tools and info here for recovering lost passwords. ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: meed a memory kick how to test for X running or not
    ... Harry Putnam wrote: ... > What is the standard way to test if a script is running in console ...
    (comp.unix.shell)
  • DWMX comes up for .net executable
    ... Then went to the console (command ... Well when I go to execute the program Dreamweaver opens up in the code ... of the picture and my program to execute through the command prompt ...
    (microsoft.public.vsnet.setup)
  • Re: Console and Form together in one application based on EXE parameters
    ... application opens a second console window, ... If the program was started from a command window, then AttachConsole will find that window and use it. ... AttachConsole will return False and AllocConsole will create a new window. ... The program is able to write to the parent's console window, but since the command prompt executed the program asynchronously, it still prompts for additional commands. ...
    (comp.lang.pascal.delphi.misc)