15
15
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:id="mgetstr" xml:lang="en">
17
<refname>mgetstr</refname>
18
<refpurpose>reads a character string from a file</refpurpose>
21
<title>Calling Sequence</title>
22
<synopsis>str = mgetstr(n, [fd])</synopsis>
25
<title>Arguments</title>
30
<para>non-negative integer: how many characters should be
39
an integer: file descriptor as returned by
40
<link linkend="mopen">mopen</link>: where characters should be read. The value <literal>-1</literal> stands for the last opened file and is the default.
47
<para>the character string to be read.</para>
53
<title>Description</title>
55
The <function>mgetstr</function> function attempts to read up
56
to <varname>n</varname> characters from a file. If end of file is
57
reached before <varname>n</varname> characters are read,
58
<function>mgetstr</function> returns the properly read values
59
only. As a consequence, when the read cursor is already at the end
60
of the file when <function>mgetstr</function> is called, it returns
61
an empty string no matter what value is provided for
66
<title>Examples</title>
67
<programlisting role="example"><![CDATA[
17
<refname>mgetstr</refname>
18
<refpurpose>reads a character string from a file</refpurpose>
21
<title>Calling Sequence</title>
22
<synopsis>str = mgetstr(n, [fd])</synopsis>
25
<title>Arguments</title>
30
<para>non-negative integer: how many characters should be
39
an integer: file descriptor as returned by
40
<link linkend="mopen">mopen</link>: where characters should be read. The value <literal>-1</literal> stands for the last opened file and is the default.
47
<para>the character string to be read.</para>
53
<title>Description</title>
55
The <function>mgetstr</function> function attempts to read up
56
to <varname>n</varname> characters from a file. If end of file is
57
reached before <varname>n</varname> characters are read,
58
<function>mgetstr</function> returns the properly read values
59
only. As a consequence, when the read cursor is already at the end
60
of the file when <function>mgetstr</function> is called, it returns
61
an empty string no matter what value is provided for
66
<title>Examples</title>
67
<programlisting role="example"><![CDATA[
68
68
fn = SCI + '/ACKNOWLEDGEMENTS'; // absolute path to some file
69
69
details = fileinfo(fn); // retrieve file details
70
70
len = details(1); // get file length
80
80
length(str4) // empty string
81
81
mclose(fd); // close file descriptor
82
82
]]></programlisting>
84
<refsection role="see also">
85
<title>See Also</title>
86
<simplelist type="inline">
88
<link linkend="mclose">mclose</link>
91
<link linkend="meof">meof</link>
94
<link linkend="mfprintf">mfprintf</link>
97
<link linkend="fprintfMat">fprintfMat</link>
100
<link linkend="mfscanf">mfscanf</link>
103
<link linkend="fscanfMat">fscanfMat</link>
106
<link linkend="mget">mget</link>
109
<link linkend="mopen">mopen</link>
112
<link linkend="mprintf">mprintf</link>
115
<link linkend="mput">mput</link>
118
<link linkend="mputstr">mputstr</link>
121
<link linkend="mseek">mseek</link>
124
<link linkend="mtell">mtell</link>
127
<link linkend="mdelete">mdelete</link>
129
<member>"Input/Output functions" section</member>
130
<!-- TODO: link to "Input/Output functions" index page -->
131
<!-- next link does not work when reading doc in scilab -->
132
<!-- <member><link linkend="section_efa4cbf5c15e166f34901f827390e756">Input/Output functions</link></member> -->
84
<refsection role="see also">
85
<title>See Also</title>
86
<simplelist type="inline">
88
<link linkend="mclose">mclose</link>
91
<link linkend="meof">meof</link>
94
<link linkend="mfprintf">mfprintf</link>
97
<link linkend="fprintfMat">fprintfMat</link>
100
<link linkend="mfscanf">mfscanf</link>
103
<link linkend="fscanfMat">fscanfMat</link>
106
<link linkend="mget">mget</link>
109
<link linkend="mopen">mopen</link>
112
<link linkend="mprintf">mprintf</link>
115
<link linkend="mput">mput</link>
118
<link linkend="mputstr">mputstr</link>
121
<link linkend="mseek">mseek</link>
124
<link linkend="mtell">mtell</link>
127
<link linkend="mdelete">mdelete</link>
129
<member>"Input/Output functions" section</member>
130
<!-- TODO: link to "Input/Output functions" index page -->
131
<!-- next link does not work when reading doc in scilab -->
132
<!-- <member><link linkend="section_efa4cbf5c15e166f34901f827390e756">Input/Output functions</link></member> -->