<HTML><HEAD><TITLE>Tcl Library Procedures - Tcl_GetStdChannel manual page</TITLE></HEAD><BODY> <H3><A NAME="M2">NAME</A></H3> Tcl_GetStdChannel, Tcl_SetStdChannel - procedures for retrieving and replacing the standard channels <H3><A NAME="M3">SYNOPSIS</A></H3> <B>#include <tcl.h></B><BR> Tcl_Channel<BR> <B>Tcl_GetStdChannel</B>(<I>type</I>)<BR> <B>Tcl_SetStdChannel</B>(<I>channel, type</I>)<BR> <H3><A NAME="M4">ARGUMENTS</A></H3> <DL> <P><DT>int <B>type</B> (in)<DD> The identifier for the standard channel to retrieve or modify. Must be one of <B>TCL_STDIN</B>, <B>TCL_STDOUT</B>, or <B>TCL_STDERR</B>. <P><DT>Tcl_Channel <B>channel</B> (in)<DD> The channel to use as the new value for the specified standard channel. <P></DL> <H3><A NAME="M5">DESCRIPTION</A></H3> Tcl defines three special channels that are used by various I/O related commands if no other channels are specified. The standard input channel has a channel name of <B>stdin</B> and is used by <B><A HREF="../TclCmd/read.htm">read</A></B> and <B><A HREF="../TclCmd/gets.htm">gets</A></B>. The standard output channel is named <B>stdout</B> and is used by <B><A HREF="../TclCmd/puts.htm">puts</A></B>. The standard error channel is named <B>stderr</B> and is used for reporting errors. In addition, the standard channels are inherited by any child processes created using <B><A HREF="../TclCmd/exec.htm">exec</A></B> or <B><A HREF="../TclCmd/open.htm">open</A></B> in the absence of any other redirections. <P> The standard channels are actually aliases for other normal channels. The current channel associated with a standard channel can be retrieved by calling <B>Tcl_GetStdChannel</B> with one of <B>TCL_STDIN</B>, <B>TCL_STDOUT</B>, or <B>TCL_STDERR</B> as the <I>type</I>. The return value will be a valid channel, or NULL. <P> A new channel can be set for the standard channel specified by <I>type</I> by calling <B>Tcl_SetStdChannel</B> with a new channel or NULL in the <I>channel</I> argument. If the specified channel is closed by a later call to <B><A HREF="../TclLib/OpenFileChnl.htm">Tcl_Close</A></B>, then the corresponding standard channel will automatically be set to NULL. <P> If <B>Tcl_GetStdChannel</B> is called before <B>Tcl_SetStdChannel</B>, Tcl will construct a new channel to wrap the appropriate platform-specific standard file handle. If <B>Tcl_SetStdChannel</B> is called before <B>Tcl_GetStdChannel</B>, then the default channel will not be created. <P> If one of the standard channels is set to NULL, either by calling <B>Tcl_SetStdChannel</B> with a null <I>channel</I> argument, or by calling <B><A HREF="../TclLib/OpenFileChnl.htm">Tcl_Close</A></B> on the channel, then the next call to <B><A HREF="../TclLib/CrtChannel.htm">Tcl_CreateChannel</A></B> will automatically set the standard channel with the newly created channel. If more than one standard channel is NULL, then the standard channels will be assigned starting with standard input, followed by standard output, with standard error being last. <H3><A NAME="M6">SEE ALSO</A></H3> <B><A HREF="../TclLib/OpenFileChnl.htm">Tcl_Close</A></B>, <B><A HREF="../TclLib/CrtChannel.htm">Tcl_CreateChannel</A></B> <H3><A NAME="M7">KEYWORDS</A></H3> <A href="../Keywords/S.htm#standard channel">standard channel</A>, <A href="../Keywords/S.htm#standard input">standard input</A>, <A href="../Keywords/S.htm#standard output">standard output</A>, <A href="../Keywords/S.htm#standard error">standard error</A> <HR><PRE> <A HREF="../copyright.htm">Copyright</A> © 1996 by Sun Microsystems, Inc. <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> </BODY></HTML>