Re: File r+ and w+ difference

* Chendu <pjsenthil@xxxxxxxxx>
| 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).

| seek $idfile 0 start

Rather than seeking around I would simply reopen the file in write
mode for the update.

| close $idt

Variable idt has never been set.