Mercurial > octave-nkf
comparison scripts/io/textread.m @ 11587:c792872f8942
all script files: untabify and strip trailing whitespace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:35:29 -0500 |
parents | 3c6e8aaa9555 |
children | f38cf6224452 |
comparison
equal
deleted
inserted
replaced
11586:12df7854fa7c | 11587:c792872f8942 |
---|---|
38 function varargout = textread (filename, format = "%f", varargin) | 38 function varargout = textread (filename, format = "%f", varargin) |
39 ## Check input | 39 ## Check input |
40 if (nargin < 1) | 40 if (nargin < 1) |
41 print_usage (); | 41 print_usage (); |
42 endif | 42 endif |
43 | 43 |
44 if (!ischar (filename) || !ischar (format)) | 44 if (!ischar (filename) || !ischar (format)) |
45 error ("textread: first and second input arguments must be strings"); | 45 error ("textread: first and second input arguments must be strings"); |
46 endif | 46 endif |
47 | 47 |
48 ## Read file | 48 ## Read file |
55 headerlines = find (strcmpi (varargin, "headerlines"), 1); | 55 headerlines = find (strcmpi (varargin, "headerlines"), 1); |
56 if (! isempty (headerlines)) | 56 if (! isempty (headerlines)) |
57 fskipl (fid, headerlines); | 57 fskipl (fid, headerlines); |
58 varargin(headerlines:headerlines+1) = []; | 58 varargin(headerlines:headerlines+1) = []; |
59 endif | 59 endif |
60 | 60 |
61 str = fread (fid, "char=>char").'; | 61 str = fread (fid, "char=>char").'; |
62 fclose (fid); | 62 fclose (fid); |
63 | 63 |
64 ## Call strread to make it do the real work | 64 ## Call strread to make it do the real work |
65 [varargout{1:max (nargout, 1)}] = strread (str, format, varargin {:}); | 65 [varargout{1:max (nargout, 1)}] = strread (str, format, varargin {:}); |
66 | 66 |
67 endfunction | 67 endfunction |