Scilab Reference Manual |
---|
file — file management
[unit [,err]]=file('open', file-name [,status] [,access [,recl]] [,format]) file(action,unit) [units [,typ [,nams [,mod [,swap]]]]] = file([unit])
file-name | : string, file name of the file to be opened | ||||||||||||||||
status | : string, The status of the file to be opened
| ||||||||||||||||
access | : string, The type of access to the file
| ||||||||||||||||
format | : string,
| ||||||||||||||||
recl | : integer,is the size of records in bytes when access="direct" | ||||||||||||||||
unit | : integer, logical unit descriptor of the opened file | ||||||||||||||||
units | : integer vector, logical unit descriptor of the opened files. Units 1 5 and 6 are reserved by the system for history file , input and output devices. | ||||||||||||||||
typs | : Character string vector, type (C or Fortran) of opened files. | ||||||||||||||||
nams | : Character string vector, pathnames of opened files. | ||||||||||||||||
mod | : file opening mode. Formed by three digits abc
| ||||||||||||||||
swap | : automatic swap switch. swap=1 if automatic swap is on. swap is always 0 for Fortran files. | ||||||||||||||||
err | : integer, error message number (see error), if open fails. If err is omitted an error message is issued. | ||||||||||||||||
action | : is one of the following strings:
|
selects a logical unit unit and manages the file file-name.
[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 read, write, readb, writb,save, load function calls.
file(action,unit) allows to close the file , or move the current file pointer .
file() returns the logical unit descriptors of the opened files. So file('close',file() ) closes all user opened files (C or Fortran type).
u=file('open',TMPDIR+'/foo','unknown') for k=1:4 a=rand(1,4) write(u,a) end file('rewind',u) x=read(u,2,4) file('close',u) // u1=file('open',TMPDIR+'/foo','unknown') u2=mopen(TMPDIR+'/foo1','wb') [units,typs,nams]=file()
<< fileinfo | fprintfMat >> |