home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / IOFUN.DI$ / FREWIND.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  801 b   |  32 lines

  1. function frewind(fid)
  2. %FREWIND Rewind an open file.
  3. %    FREWIND(FID) sets the file pointer to the beginning of the 
  4. %    file associated with file identifier fid.
  5. %
  6. %    WARNING: Rewinding a fid associated with a tape device may not work
  7. %         even though no error message is generated!
  8.  
  9. %    Jan 92 - 30
  10. %       Jul 92 - 13
  11. %    Nov 92 - 2, 3
  12. %    Martin Knapp-Cordes
  13. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  14. %
  15. %----------------------------------------------------------------------------
  16. %
  17.     if (nargin ~= 1)
  18.         error ('Wrong number of arguments.')
  19.     end
  20.  
  21.     fidvec = fopen('all');
  22.     for i = 1:size(fidvec,2)
  23.          if (fid == fidvec(i))
  24.         status = fseek(fid, 0, -1);
  25.         if (status == -1)
  26.             error ('Rewind failed.')
  27.         end
  28.         return
  29.          end
  30.     end
  31.     error ('Invalid file identifier.')
  32.