mopen opens a file in Scilab Calling Sequence [fd, err] = mopen(file [, mode, swap ]) Arguments file a character string containing the path of the file to open. mode a character string specifying the access mode requested for the file. swap a scalar. If swap is present and swap = 0 then automatic bytes swap is disabled. The default value is 1. err a scalar. Error indicator. error value: error message: 0 No error -1 no more logical units -2 cannot open file -3 no more memory -4 invalid name -5 invalid status fd a scalar: a file descriptor (it's a positive integer). Description mopen may be used to open a file in a way compatible with the C fopen procedure. Without swap argument the file is supposed to be coded in "little endian IEEE format" and data are swapped if necessary to match the IEEE format of the processor. The mode parameter controls the access type requested for the stream. The parameter can have one of the following values: r opens for reading (default). The file must exist, otherwise it fails. w opens for writing. If the file exists, its contents are destroyed. a opens for appending. It creates the file if it does not exist. r+ opens for both reading and writing. The file must exist, otherwise it fails. w+ opens for both reading and writing. If the file exists, its contents are destroyed. a+ opens for both reading and appending. It creates the file if it does not exist. In addition, the following characters can be used to specify the type of file: t text file. b binary file (default). The default access mode is 'rb' (binary file reading). Note: on Windows, in text file mode, CR (carriage return) - LF (linefeed) combinations are translated into LF on reading, and LF are translated to CR-LF combinations on writing. When you open a file for update, you can perform both input and output operations on the resulting stream. However, an output operation cannot be directly followed by an input operation without a file-positioning operation (mseek function). Also, an input operation cannot be directly followed by an output operation without an intervening file positioning operation, unless the input operation encounters the end of the file. When you open a file for append (that is, when the mode parameter is a or a+), it is impossible to overwrite information already in the file. You can use the mseek function to reposition the file pointer to any position in the file, but when output is written to the file, the current file pointer is ignored. All output is written at the end of the file and the file pointer is repositioned to the end of the output. To open files in a way compatible with Fortran-like functions use function file. Examples See Also file mclose merror meof mfprintf fprintfMat mfscanf fscanfMat mget mgetl mgetstr mprintf mput mputl mputstr mseek mtell mdelete