%FOPEN  Open file.
%   FID = FOPEN(FILENAME,PERMISSION) opens the specified file with
%   the specified PERMISSION. If the file is opened for reading and it
%   is not found in the current working directory, FOPEN searches down
%   MATLAB's search path.  Permission is one of the strings:
%   
%       'r'     read
%       'w'     write (create if necessary)
%       'a'     append (create if necessary)
%       'r+'    read and write (do not create)
%       'w+'    truncate or create for read and write
%       'a+'    read and append (create if necessary)
%       'W'     write without automatic flushing
%       'A'     append without automatic flushing
%   
%   Files can be opened in binary mode (the default) or in text mode.
%   In binary mode no characters get singled out for special treatment.
%   In text mode line separators can get special treatment whereby
%   characters are deleted on input before they reach MATLAB and added
%   on output.  To open in text mode, add 't' to the permission string,
%   for example 'rt' and 'wt+'.  (On Unix and Macintosh systems, text
%   and binary mode are the same so this has no effect. But on PC and
%   VMS systems this is critical.)
%
%   If the open is successful, FID gets a scalar MATLAB integer, the
%   file identifier, to be used as the first argument to other FileIO
%   routines. If the open was not successful, -1 is returned for FID.
%
%   Two file identifiers are automatically available and need not be
%   opened.  They are FID=1 (standard output) and FID=2 (standard error).
%   
%   [FID, MESSAGE] = FOPEN(FILENAME,PERMISSION) returns a system 
%   dependent error message if the open is not successful.
%
%   [FID, MESSAGE] = FOPEN(FILENAME,PERMISSION,MACHINEFORMAT) opens the
%   specified file with the specified PERMISSION and treats data read
%   using FREAD or data written using FWRITE as having a format given
%   by MACHINEFORMAT. MACHINEFORMAT is one of the following strings:
%
%   'native'      or 'n' - local machine format - the default
%   'ieee-le'     or 'l' - IEEE floating point with little-endian
%                          byte ordering
%   'ieee-be'     or 'b' - IEEE floating point with big-endian
%                          byte ordering
%   'vaxd'        or 'd' - VAX D floating point and VAX ordering
%   'vaxg'        or 'g' - VAX G floating point and VAX ordering
%   'cray'        or 'c' - Cray floating point with big-endian
%                          byte ordering
%   'ieee-le.l64' or 'a' - IEEE floating point with little-endian
%                          byte ordering and 64 bit long data type
%   'ieee-be.l64' or 's' - IEEE floating point with big-endian byte
%                          ordering and 64 bit long data type.
%   
%   [FILENAME,PERMISSION,MACHINEFORMAT] = FOPEN(FID) returns the filename,
%   permission, and machineformat associated with the given file
%   identifier. If FID does not exist then an empty string is returned for
%   each variable.
%
%   FIDS = FOPEN('all') returns a row vector, the file identifiers for 
%   all the files currently opened by the user (but not 1 or 2).
%   
%   The 'W' and 'A' permissions are designed for use with tape drives and
%   do not automatically perform a flush of the current output buffer
%   after output operations. For example, open a 1/4" cartridge tape on a
%   SPARCstation for writing with no auto-flush:
%
%           fid = fopen('/dev/rst0','W')
%   
%   See also FCLOSE, FREWIND, FREAD, FWRITE, FPRINTF.

%   FID = FOPEN(FILENAME) assumes a permission of 'r'.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 5.9 $  $Date: 1998/08/31 15:24:55 $
%   Built-in function.
