Accessing files
Tcl allows us to read from and write to files by using channels. A channel can be an open file, but it can also be a network socket, a pipe, or any other channel type. Depending on the type of the channel, it can support reading from it, writing to it, or both.
Tcl comes with three default channels—stdin, stdout
, and stderr
. These channels correspond to the standard input, standard output, and standard error channels of operating systems. Standard input can be used to read information from the user, standard output should be used to write information to user, and standard error is used to write errors. Depending on how our application is run, these channels can be redirected from/to files.
In the case of Microsoft Windows and applications using the GUI version of Tcl, invoked using the wish or tclkit commands, standard channels are not available. This is because graphical applications in Microsoft Windows do not have standard consoles. In such cases, an equivalent of these...