Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cannot find channel

1,138 views
Skip to first unread message

Razzel

unread,
Jan 27, 2005, 5:33:48 AM1/27/05
to
After successfully reading a byte from the input file, a proc in my
program then recalls the proc via an "after" command. On this second
trip (the file identifier is the same per a puts before the offending
gets) the gets command evokes an error message saying:
"can not find channel named: file4".
Can someone explain why it can read the file on the first pass but not
the second?

BTW the file is opened outside (and before) the proc is called.
Thanks,
Ron

Jeff Hobbs

unread,
Jan 27, 2005, 12:18:36 PM1/27/05
to Razzel
Razzel wrote:

Is it really? Try puts [file channels] to verify.

--
Jeff Hobbs, The Tcl Guy
http://www.ActiveState.com/, a division of Sophos

Razzel

unread,
Jan 29, 2005, 4:24:46 AM1/29/05
to
Razzel wrote:

SOLUTION:
as usual the last 1% takes 99% of the effort.
A proc is called from the main line code in which a data file is opened
for reading within the proc. Within the proc the proc is re-invoked as
the last command using an after command. Because the file was closed
following the initial invocation in the main line code, this prevented
file4 channel from being found. Hence, remember that even though the
proc is recalled recursively from within itself, the first invocation
returns to the main line code and closed the file. Subsequent proc
invocations scheduled by the after command find a gets without a file
handle. Ta Daaaa!
Ron

Ralf Fassel

unread,
Jan 31, 2005, 3:44:25 PM1/31/05
to
* Razzel <log...@zipcon.com>

| Hence, remember that even though the proc is recalled recursively
| from within itself, the first invocation returns to the main line
| code and closed the file. Subsequent proc invocations scheduled by
| the after command find a gets without a file handle.

Sounds like the `fileevent' command could be useful here instead of
`after'?

http://wiki.tcl.tk/fileevent

HTH
R'

0 new messages