home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / IOFUN.DI$ / FOPEN.M < prev    next >
Encoding:
Text File  |  1993-03-21  |  3.0 KB  |  68 lines

  1. %FOPEN    Open file.
  2. %    FID = FOPEN('filename',permission) opens the specified file with
  3. %    the specified permission. Permission is one of the strings:
  4. %    
  5. %        'r'        read
  6. %        'w'        write (create if necessary)
  7. %        'a'        append (create if necessary)
  8. %        'r+'    read and write (do not create)
  9. %        'w+'    truncate or create for read and write
  10. %        'a+'    read and append (create if necessary)
  11. %        'W'     write without automatic flushing
  12. %        'A'     append without automatic flushing
  13. %    
  14. %    By default, files are opened in binary mode. To open a text file,
  15. %    add 't' to the permission string, for example 'rt' and 'wt+'. (On
  16. %    Unix systems, text and binary files are the same so this has no
  17. %    effect. But on PC, Macintosh, and VMS systems this is critical.)
  18. %
  19. %    FID = FOPEN('filename') assumes a permission of 'r'.
  20. %    
  21. %    If the open is successful, FID gets a scalar MATLAB integer, the
  22. %    file identifier, to be used as the first argument to other FileIO
  23. %    routines. If the open was not successful, -1 is returned for FID.
  24. %    
  25. %    Three file identifiers are automatically available and need not be
  26. %    opened.  They are fid=0 (standard input), fid=1 (standard output),
  27. %    and fid=2 (standard error).
  28. %    
  29. %    [FID, MESSAGE] = FOPEN('filename',permission) returns a system 
  30. %       dependent error message if the open is not successful.
  31. %    
  32. %    FOPEN('all') returns a row vector, the file identifiers for all the
  33. %    files currently opened by the user. (But not 0, 1, and 2.)
  34. %    
  35. %    [FILENAME,PERMISSION] = FOPEN(FID) returns the filename and 
  36. %       permission associated with the given file identifier.
  37. %
  38. %    If the file is opened in 'r' mode and it is not found in the current
  39. %    working directory, FOPEN searches down MATLAB's search path.
  40. %
  41. %    [FID, MESSAGE] = FOPEN('filename',permission, machineformat) opens the
  42. %    specified file with the specified permission and treats data read
  43. %    using FREAD or data written using FWRITE as having a format given
  44. %    by machineformat. machineformat is one of the following strings:
  45. %
  46. %    'native'  or 'n' - local machine format - the default
  47. %    'ieee-le' or 'l' - IEEE floating point with little-endian byte ordering
  48. %    'ieee-be' or 'b' - IEEE floating point with big-endian byte ordering
  49. %    'vaxd'    or 'd' - VAX D floating point and VAX ordering
  50. %    'vaxg'    or 'g' - VAX G floating point and VAX ordering
  51. %    'cray'      or 'c' - Cray floating point with big-endian byte ordering
  52. %    
  53. %    [FILENAME,PERMISSION,MACHINEFORMAT] = FOPEN(FID) returns the filename,
  54. %    permission, and machineformat associated with the given file
  55. %    identifier.
  56. %
  57. %       The 'W' and 'A' permissions are designed for use with tape drives and
  58. %    do not automatically perform a flush of the current output buffer
  59. %    after output operations. For example, open a 1/4" cartridge tape on a
  60. %    SPARCstation for writing with no auto-flush:
  61. %
  62. %               fid = fopen('/dev/rst0','W')
  63. %    
  64. %    See also FCLOSE, FREAD, FWRITE, FPRINTF.
  65.  
  66. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  67. %    Built-in function.
  68.