Help with Tcl...

Hello Tcl Experts,

set i 0

while { $i < 10 } {
puts "$i"
incr i
}

I am trying to print the value of "i" at the same place. i.e. it should first print "1", then in next iteration print "2" over the location of "1" and so on.... (i.e. in every iteration, delete the previous number and print the next number at the same place)...
I tried various combinations of switches(blindly), but couldn't make it work.. The next value is always printed in new line... :frowning:

Present Output:

0
1
2
3
4
5
6
7
8
9

I want:

9

or atleast

1 2 3 4 5 6 7 8 9

I hope I am able to make myself clear.

Thanks...

Hi.

#!/usr/bin/env tclsh

# @(#) tcl1     Demonstrate tclsh feature.

set i 0

while { $i < 10 } {
  puts -nonewline "$i"
  incr i
}
puts ""

exit 0

Producing:

% ./tcl1
0123456789

See any of the several hits for Google tcl puts ... cheers, drl

thanks..
should have googled it... :slight_smile: