Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"can not find channel named" error

Status
Not open for further replies.

sudhan1980

Programmer
May 30, 2012
2
0
0
US
Dear all,

I use Tip 86 to trace execution of script and like to print the traced info of everyline through my own procedure call print_lines. Script throws error , when i try to open a file and access the contents.

Note 1: Instead of proc call "print_lines", if i specify standard channel "stdout". script executes smoothly.

Code :
------
proc print_lines { args } {

puts "Argument List : $args"
}

trace execution print_lines

set fd [ open "/tmp/user/hello.txt" "r" ]

while { [ gets $fd readdata ] != -1 } {

puts $readdata
}

close $fd

Error : "can not find channel named print_lines "file5

Thanks for all your solutions in advance....
 
I think you're not using "trace" correctly. I see the syntax as: trace add execution name ops commandPrefix
where from the Docs:
TclHelp said:
Arrange for commandPrefix to be executed (with additional arguments) whenever command name is executed, with traces occurring at the points indicated by the list ops. Name will be resolved using the usual namespace resolution rules used by commands. If the command does not exist, an error will be thrown.

_________________
Bob Rashkin
 
I use the trace syntax available in the TIP( TCL improvement Proposal )86.

trace execution

A new execution subcommand to the trace command.

trace execution target ?level?

This arranges for an execution trace to be setup for commands at nesting level or above, thereby providing a simple Tcl interface for tracing commands to say, implement a debugger. With no arguments, the current target is returned. If target is the empty string, the execution trace is removed. The target argument is assumed to be a command string to be executed. When level is not specified, it defaults to 0, meaning trace all commands. For each traced command, the following data will be produced:

•linenumber

The line number the instruction begins on.

•filename

The fully normalized file name.

•nestlevel

The nesting level of the command.

•stacklevel

The stack call level as per info level.

•curnsproc

The current fully qualified namespace/function.

•cmdname

The fully qualified command name of the command to be invoked.

•command

The command line to be executed including arguments.

•flags

Integer bit flags, currently bit 1 is set for breakpoint.

The target is presumed to be a valid Tcl command onto which is appended the above arguments before evaluation. Any return from the command other than a normal return results in the command not being executed. As with all traces, execution tracing is disabled within a trace handler.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top