Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't output to console in real time 1

Status
Not open for further replies.

carm67

Programmer
Apr 18, 2005
2
US
Hi,

I'm new to Tcl and have been trying to write a relatively simple program. I'm running WindowsXP and have Tcl 8.4.9 installed from ActiveState. I was having troubles with the program I had so I simplified the problem down to this.

# START

catch {console show}

set i 1;

fconfigure stdout -buffering none
while {$i <= 1400} {

puts stdout "Current val of i:"
puts stdout $i
flush stdout;

incr i
}
puts stdout "done!"

# FINISH

At this point that is all I'm trying to run. The problem is, when I run this script the computer just sits there for a few seconds with the hour glass turning and then prints out the last few hundred lines to the console in one burst. What I want though is to see all 1400 numbers being printed out in real time. I added the fconfigure and flush stdout lines to see if they helped but they didn't. From what I understand, stdout is supposed to be line buffered by default anways. I also ran the script on Suse 9.2 and it printed them out correctly. Is there an issue with Windows or is there something simple I'm missing? Thanks a lot. I appreciate it.

-Sean
 
I think what you want is achieved by placing an update statement after the flush stdout statement:
Code:
while {$i <= 1400} {

   puts stdout "Current val of i:"
   puts stdout $i
   flush stdout
   [red]update[/red]
   incr i
}

_________________
Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top