Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function
[unit, err] = file("open", file-name [,status] [,access [,recl]] [,format]) file("close", unit) file("rewind", unit) file("backspace", unit) file("last", unit) [units, typ, nams, mod, swap] = file() [units, typ, nams, mod, swap] = file(unit)
string, file name of the file to be openedThis function can not open files whose path has non-ascii UTF characters (accented, etc). In this case, mopen() must be used.
string, The status of the file to be opened
file must not exist new file (default)
file must already exists.
file is to be deleted at end of session
string, The type of access to the file
sequential access (default)
for a formatted file (default)
integer,is the size of records in bytes when
integer, logical unit descriptor of the opened file
integer vector, logical unit descriptor of the opened files. Units 5 and 6 (%io) are reserved by the system for input and output devices.
Character string vector, type (C or Fortran) of opened files.
Character string vector, pathnames of opened files.
file opening mode. Formed by three digits abc:
>Fortran files a 0 stands for formatted and 1 for unformatted (binary) b 0 stands for sequential access and 1 for direct access c 0 stands for "new", 1 for "old", 2 for "scratch" and 3 for "unknown" C files a 1 stands for "r" (read), 2 stands for "w" (write) and 3 for "a" (append) b is 1 if file has been opened with a "+" (updating) mode c is 1 if file has been opened with a "b" (binary) mode
automatic swap switch. swap=1 if automatic swap is on. swap is always 0 for Fortran files.
integer code returned if opening the file fails. If
erris omitted, an error message is issued.
65 File already used 66 Too many files opened! 67 Unknown file format 240 The file already exists or directory write access denied. 241 The file does not exist or read access denied.
file(…) selects a logical unit
unit and manages
- [unit [,err]]=file("open", file-name [,status] [,access [,recl]][,format])
allows to open a file with specified properties and to get the associated unit number
unit. This unit number may be used for further actions on this file or as file descriptor in
- file("close", unit)
allows to close the file, or move the current file pointer.
- file("rewind", unit)
puts the pointer at the beginning of the file.
- file("backspace", unit)
puts the pointer at the beginning of last record.
- file("last", unit)
puts the pointer after last record.
returns the descriptors of the opened files.
To test whether a file whose unit is
file(id)~=may be used.
To close all user opened files (C or Fortran type),
file("close",file())may be used.
- isfile — checks whether argument is an existing file
- read — matrices read
- readb — fortran file binary read
- write — write in a formatted file
- writb — fortran file binary write
- mopen — opens a file in Scilab
- save — Saves some chosen variables in a binary data file
- load — Loads some archived variables, a saved graphic figure, a library of functions
- uigetfile — dialog window to get a file(s) name(s), path and filter index
|6.0.0||stderr is inserted in the output of file() as units(1)=0, typ(1)="STD" and nams(1)="stderr".|
|Report an issue|
|<< OS_commands||Input/Output functions||getio >>|