projman/hlp/en/tcl/seek.htm
2015-10-19 14:27:31 +04:00

52 lines
2.7 KiB
HTML

<HTML><HEAD><TITLE>Tcl Built-In Commands - seek manual page</TITLE></HEAD><BODY>
<H3><A NAME="M2">NAME</A></H3>
seek - Change the access position for an open channel
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>seek </B><I>channelId offset </I>?<I>origin</I>?<BR>
<H3><A NAME="M4">DESCRIPTION</A></H3>
Changes the current access position for <I>channelId</I>.
<I>ChannelId</I> must be a channel identifier such as returned from a
previous invocation of <B><A HREF="../TkCmd/open.htm">open</A></B> or <B><A HREF="../TkCmd/socket.htm">socket</A></B>.
The <I>offset</I> and <I>origin</I>
arguments specify the position at which the next read or write will occur
for <I>channelId</I>. <I>Offset</I> must be an integer (which may be
negative) and <I>origin</I> must be one of the following:
<P>
<DL>
<P><DT><A NAME="M5"><B>start</B></A><DD>
The new access position will be <I>offset</I> bytes from the start
of the underlying file or device.
<P><DT><A NAME="M6"><B>current</B></A><DD>
The new access position will be <I>offset</I> bytes from the current
access position; a negative <I>offset</I> moves the access position
backwards in the underlying file or device.
<P><DT><A NAME="M7"><B>end</B></A><DD>
The new access position will be <I>offset</I> bytes from the end of
the file or device. A negative <I>offset</I> places the access position
before the end of file, and a positive <I>offset</I> places the access
position after the end of file.
<P></DL>
<P>
The <I>origin</I> argument defaults to <B>start</B>.
<P>
The command flushes all buffered output for the channel before the command
returns, even if the channel is in nonblocking mode.
It also discards any buffered and unread input.
This command returns an empty string.
An error occurs if this command is applied to channels whose underlying
file or device does not support seeking.
<P>
Note that <I>offset</I> values are byte offsets, not character
offsets. Both <B>seek</B> and <B><A HREF="../TkCmd/tell.htm">tell</A></B> operate in terms of bytes,
not characters, unlike <B><A HREF="../TkCmd/read.htm">read</A></B>.
<H3><A NAME="M8">SEE ALSO</A></H3>
<B><A HREF="../TkCmd/file.htm">file</A></B>, <B><A HREF="../TkCmd/open.htm">open</A></B>, <B><A HREF="../TkCmd/close.htm">close</A></B>, <B><A HREF="../TkCmd/gets.htm">gets</A></B>, <B><A HREF="../TkCmd/tell.htm">tell</A></B>
<H3><A NAME="M9">KEYWORDS</A></H3>
<A href="../Keywords/A.htm#access position">access position</A>, <A href="../Keywords/F.htm#file">file</A>, <A href="../Keywords/S.htm#seek">seek</A>
<HR><PRE>
<A HREF="../copyright.htm">Copyright</A> &#169; 1993 The Regents of the University of California.
<A HREF="../copyright.htm">Copyright</A> &#169; 1994-1996 Sun Microsystems, Inc.
<A HREF="../copyright.htm">Copyright</A> &#169; 1995-1997 Roger E. Critchlow Jr.</PRE>
</BODY></HTML>