| Ralf Fassel 2007-06-28, 4:18 am |
| * Chendu <pjsenthil@gmail.com>
| proc Num {} {
| if { [file exists [pwd]/temp/idmt] } {
| set idfile [open "[pwd]/temp/id_cnt" r+ 0600]
You check for one file but open another? Better skip the 'file exist'
and simply try to open the file in read-only mode. If the open
succeeds, the file is already there.
| } else {
| file mkdir temp
| set idfile [open "[pwd]/temp/idmt" r+ 0600]
| puts $id 001
Not sure whether you would need to rewind before reading the file
after a write.
| set id [read $idfile]
As Gerald pointed out in another message, most likely you need 'read
-nonewline' here in order to treat 'id' as an integer. Also you need
to deal with the possibility that 'id' is non-numeric after the read
(like the empty string in your case).
| s $idfile 0 start
Rather than s ing around I would simply reopen the file in write
mode for the update.
| close $idt
Variable idt has never been set.
HTH
R'
|