⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 read.n

📁 tcl是工具命令语言
💻 N
字号:
'\"'\" Copyright (c) 1993 The Regents of the University of California.'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" RCS: @(#) $Id: read.n,v 1.7 2001/09/14 19:20:40 andreas_kupries Exp $'\" .so man.macros.TH read n 8.1 Tcl "Tcl Built-In Commands".BS'\" Note:  do not modify the .SH NAME line immediately below!.SH NAMEread \- Read from a channel.SH SYNOPSIS\fBread \fR?\fB\-nonewline\fR? \fIchannelId\fR.sp\fBread \fIchannelId numChars\fR.BE.SH DESCRIPTION.PPIn the first form, the \fBread\fR command reads all of the data from\fIchannelId\fR up to the end of the file.  If the \fB\-nonewline\fRswitch is specified then the last character of the file is discardedif it is a newline.  In the second form, the extra argument specifieshow many characters to read.  Exactly that many characters will beread and returned, unless there are fewer than \fInumChars\fR left inthe file; in this case all the remaining characters are returned.  Ifthe channel is configured to use a multi-byte encoding, then thenumber of characters read may not be the same as the number of bytesread..PP.VS\fIChannelId\fR must be an identifier for an open channel such as theTcl standard input channel (\fBstdin\fR), the return value from aninvocation of \fBopen\fR or \fBsocket\fR, or the result of a channelcreation command provided by a Tcl extension. The channel must havebeen opened for input..VE.PPIf \fIchannelId\fR is in nonblocking mode, the command may not read asmany characters as requested: once all available input has been read,the command will return the data that is available rather thanblocking for more input.  If the channel is configured to use amulti-byte encoding, then there may actually be some bytes remainingin the internal buffers that do not form a complete character.  Thesebytes will not be returned until a complete character is available orend-of-file is reached.  The \fB\-nonewline\fR switch is ignored ifthe command returns before reaching the end of the file..PP\fBRead\fR translates end-of-line sequences in the input intonewline characters according to the \fB\-translation\fR optionfor the channel.See the \fBfconfigure\fR manual entry for a discussion on ways inwhich \fBfconfigure\fR will alter input..SH "USE WITH SERIAL PORTS"'\" Note:  this advice actually applies to many versions of TclFor most applications a channel connected to a serial port should beconfigured to be nonblocking: \fBfconfigure \fIchannelId \fB\-blocking\fI0\fR.  Then \fBread\fR behaves much like described above.  Caremust be taken when using \fBread\fR on blocking serial ports:.TP\fBread \fIchannelId numChars\fR In this form \fBread\fR blocks until \fInumChars\fR have been receivedfrom the serial port..TP\fBread \fIchannelId\fR In this form \fBread\fR blocks until the reception of the end-of-filecharacter, see \fBfconfigure -eofchar\fR. If there no end-of-filecharacter has been configured for the channel, then \fBread\fR willblock forever..SH "SEE ALSO"file(n), eof(n), fblocked(n), fconfigure(n), Tcl_StandardChannels(3).SH KEYWORDSblocking, channel, end of line, end of file, nonblocking, read, translation, encoding

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -