- Ajuda Scilab
- Arquivos : funções de Entrada/Saída
Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function
read a character string from a file
str = mgetstr(n, [fd])
Non negative integer: how many characters should be read.
Integer file descriptor as returned by
mopen: where characters should be read. The value
-1stands for the last opened file and is the default.
The character string read.
mgetstr function attempts to read up
n characters from a file. If end of file is
n characters are read,
mgetstr returns the properly read values
only. As a consequence, when the read cursor is already at the end
of the file when
mgetstr is called, it returns
an empty string no matter what value is provided for
fn = SCI + '/ACKNOWLEDGEMENTS'; // absolute path to some file details = fileinfo(fn); // retrieve file details len = details(1); // get file length fd = mopen(fn, 'rt'); // open file as text with read mode str1 = mgetstr(33, fd) // read 33 characters from fd length(str1) // 33 characters read str2 = mgetstr(272, fd) // read the next 272 characters from fd length(str2) // 272 characters read mseek(len - 5); // jump to the 5th character before end of file str3 = mgetstr(10, fd) // try to read 10 characters: returns 5 characters only, no more available length(str3) // yes, there are 5 characters: you just can't see the linefeed :) str4 = mgetstr(10, fd) // read 10 characters: returns empty string length(str4) // empty string mclose(fd); // close file descriptor
- mclose — close an opened file
- meof — check if end of file has been reached
- mfprintf — converts, formats, and writes data to a file
- fprintfMat — Write a matrix in a file.
- mfscanf — reads input from the standard input (interface to the C scanf function)
- fscanfMat — Reads a Matrix from a text file.
- mget — reads byte or word in a given binary format and convert to double
- mgetstr — read a character string from a file
- mopen — open a file
- mprintf — converts, formats, and writes data to the main scilab window
- mput — writes byte or word in a given binary format
- mputstr — write a character string in a file
- mseek — set current position in binary file.
- mtell — binary file management
- mdelete — Delete file(s)
- "Input/Output functions" section
|<< mgetl||Arquivos : funções de Entrada/Saída||mkdir >>|