Add example for meof, mputstr & mtell 89/9889/3
Sylvestre Ledru [Fri, 30 Nov 2012 13:21:59 +0000 (14:21 +0100)]
Change-Id: If7e350540f76c4eddd39aea501d35e72d8ec53bc

scilab/modules/fileio/help/en_US/meof.xml
scilab/modules/fileio/help/en_US/mputstr.xml
scilab/modules/fileio/help/en_US/mtell.xml

index 3142be2..f53f672 100644 (file)
             flag to zero.
         </para>
     </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+
+// Write a temporary file with some text in it
+this_file = pathconvert(TMPDIR+"/mputstr.txt", %F);
+
+fd = mopen(this_file, "wt");
+mputstr("Scilab is a numerical computing software.", fd);
+mclose(fd);
+
+fd = mopen(this_file,'rt');
+i = 0;
+while ~meof(fd) do
+   mfscanf(1, fd, "%c");
+   i = i + 1;
+end
+
+mclose(fd);
+
+disp("Scilab has found " + string(i) + " chars in the file");
+
+ ]]></programlisting>
+    </refsection>
+
     <refsection role="see also">
         <title>See Also</title>
         <simplelist type="inline">
index 54980ae..33f7817 100644 (file)
             The <function>mputstr</function> function allows to write a character string <varname>str</varname> in a binary file.
         </para>
     </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+
+this_file = pathconvert(TMPDIR+"/mputstr.txt", %F);
+
+fd = mopen(this_file, "wt");
+mputstr("Scilab", fd);
+mclose(fd);
+
+mgetl(this_file) // Scilab
+
+ ]]></programlisting>
+    </refsection>
     <refsection role="see also">
         <title>See Also</title>
         <simplelist type="inline">
index e90227a..d1387bf 100644 (file)
@@ -14,7 +14,7 @@
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="mtell">
     <refnamediv>
         <refname>mtell</refname>
-        <refpurpose>binary file management</refpurpose>
+        <refpurpose>Returns the offset of the current byte relative to the beginning of a file</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
         <title>Calling Sequence</title>
             the named stream <varname>fd</varname>.
         </para>
     </refsection>
+
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+// Open in binary write a temporary file
+testFile=TMPDIR + '/testFile.bin';
+fd = mopen(testFile,'wb');
+
+mput(42,'d'); // Will open fd transparently to write 42
+mtell() // Will return 8, the current position in the file descriptor
+
+mput(42+2,'d', fd); // Will open fd transparently to write 42
+mtell(fd) // Will return 16, the current position in the file descriptor
+
+mseek(0, fd); // return at the beginning of the file
+mtell(fd) // Will return 0
+
+mclose(fd);
+ ]]></programlisting>
+    </refsection>
+
     <refsection role="see also">
         <title>See Also</title>
         <simplelist type="inline">