Advanced Search
Mail us
Home    Manuel    Links    Faq    Submit a tcl/tk Reference    Contact Us

    Some examples tcl/tk codes     Man of Bwidget     Man of blt     mkwidget screenshots     TkOgl     Video Demo real.


  Puts bugs
 
 The following Tcl procedure may fail on Windows NT, depending on the amount of data written to the file: 

proc testPuts { fileName output times } {
set fileID [ open $fileName w ]
for { set i 0 } { $i < $times } { incr i } {
puts $fileID $output
}
close $fileID
}

When it fails, there are only a couple of characters in the output file (basically garbage). The Tcl error reports back: 

error writing "fileX": No error

For example, if I call: 

testPuts {C:/TestFile} {HI THERE} 455

it works perfectly well. However, if I call: 

testPuts {C:/TestFile} {HI THERE} 456

it fails. 

You can work around this bug by flushing the file descriptor after each puts call, like the following: 

proc testPuts { fileName output times } {
set fileID [ open $fileName w ]
for { set i 0 } { $i < $times } { incr i } {
puts $fileID $output
flush $fileID
}
close $fileID
}

The big question is whether this is a bug in Tcl or Windows NT 3.51. Has anyone seen this before or have any related information?
If it is a bug in Windows NT, will Tcl7.5b2 handle this? 

-Brian L. Rubow