Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 254

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>File Positioning - GNU Octave</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Octave">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="C_002dStyle-I_002fO-Functions.html#C_002dStyle-I_002fO-Functions" title="C-Style I/O Functions">
<link rel="prev" href="EOF-and-Errors.html#EOF-and-Errors" title="EOF and Errors">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="File-Positioning"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="EOF-and-Errors.html#EOF-and-Errors">EOF and Errors</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="C_002dStyle-I_002fO-Functions.html#C_002dStyle-I_002fO-Functions">C-Style I/O Functions</a>
<hr>
</div>

<h4 class="subsection">14.2.19 File Positioning</h4>

<p>Three functions are available for setting and determining the position of
the file pointer for a given file.

<!-- ftell src/file-io.cc -->
   <p><a name="doc_002dftell"></a>

<div class="defun">
&mdash; Built-in Function:  <b>ftell</b> (<var>fid</var>)<var><a name="index-ftell-1019"></a></var><br>
<blockquote><p>Return the position of the file pointer as the number of characters
from the beginning of the file <var>fid</var>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dfseek.html#doc_002dfseek">fseek</a>, <a href="doc_002dfopen.html#doc_002dfopen">fopen</a>, <a href="doc_002dfclose.html#doc_002dfclose">fclose</a>. 
</p></blockquote></div>

<!-- fseek src/file-io.cc -->
   <p><a name="doc_002dfseek"></a>

<div class="defun">
&mdash; Built-in Function:  <b>fseek</b> (<var>fid, offset, origin</var>)<var><a name="index-fseek-1020"></a></var><br>
<blockquote><p>Set the file pointer to any location within the file <var>fid</var>.

        <p>The pointer is positioned <var>offset</var> characters from the <var>origin</var>,
which may be one of the predefined variables <code>SEEK_CUR</code><!-- /@w --> (current
position), <code>SEEK_SET</code><!-- /@w --> (beginning), or <code>SEEK_END</code><!-- /@w --> (end of
file) or strings "cof", "bof" or "eof".  If <var>origin</var> is omitted,
<code>SEEK_SET</code><!-- /@w --> is assumed.  The offset must be zero, or a value returned
by <code>ftell</code> (in which case <var>origin</var> must be <code>SEEK_SET</code><!-- /@w -->).

        <p>Return 0 on success and -1 on error. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dftell.html#doc_002dftell">ftell</a>, <a href="doc_002dfopen.html#doc_002dfopen">fopen</a>, <a href="doc_002dfclose.html#doc_002dfclose">fclose</a>. 
</p></blockquote></div>

<!-- SEEK_SET src/file-io.cc -->
   <p><a name="doc_002dSEEK_005fSET"></a>

<div class="defun">
&mdash; Built-in Function:  <b>SEEK_SET</b> ()<var><a name="index-SEEK_005fSET-1021"></a></var><br>
&mdash; Built-in Function:  <b>SEEK_CUR</b> ()<var><a name="index-SEEK_005fCUR-1022"></a></var><br>
&mdash; Built-in Function:  <b>SEEK_END</b> ()<var><a name="index-SEEK_005fEND-1023"></a></var><br>
<blockquote><p>Return the numerical value to pass to <code>fseek</code> to perform
one of the following actions:
          <dl>
<dt><code>SEEK_SET</code><dd>Position file relative to the beginning.

          <br><dt><code>SEEK_CUR</code><dd>Position file relative to the current position.

          <br><dt><code>SEEK_END</code><dd>Position file relative to the end. 
</dl>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dfseek.html#doc_002dfseek">fseek</a>. 
</p></blockquote></div>

<!-- frewind src/file-io.cc -->
   <p><a name="doc_002dfrewind"></a>

<div class="defun">
&mdash; Built-in Function:  <b>frewind</b> (<var>fid</var>)<var><a name="index-frewind-1024"></a></var><br>
<blockquote><p>Move the file pointer to the beginning of the file <var>fid</var>, returning
0 for success, and -1 if an error was encountered.  It is equivalent to
<code>fseek (</code><var>fid</var><code>, 0, SEEK_SET)</code>. 
</p></blockquote></div>

   <p>The following example stores the current file position in the variable
<code>marker</code>, moves the pointer to the beginning of the file, reads
four characters, and then returns to the original position.

<pre class="example">     marker = ftell (myfile);
     frewind (myfile);
     fourch = fgets (myfile, 4);
     fseek (myfile, marker, SEEK_SET);
</pre>
   <!-- DO NOT EDIT!  Generated automatically by munge-texi.pl. -->
<!-- Copyright (C) 1996-2012 John W. Eaton -->
<!-- This file is part of Octave. -->
<!-- Octave is free software; you can redistribute it and/or modify it -->
<!-- under the terms of the GNU General Public License as published by the -->
<!-- Free Software Foundation; either version 3 of the License, or (at -->
<!-- your option) any later version. -->
<!-- Octave is distributed in the hope that it will be useful, but WITHOUT -->
<!-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -->
<!-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License -->
<!-- for more details. -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with Octave; see the file COPYING.  If not, see -->
<!-- <http://www.gnu.org/licenses/>. -->
   </body></html>