function status = fcomment(infile, outfile) % fcomment -- Convert text file for "load" compatibility. % fcomment('infile', 'outfile') converts the "infile" to the % "outfile" by prepending each comment-line with '%' and % passing all other lines intact. The "uigetfile" and % "uiputfile" dialogs are invoked if areguments are not % provided. % Copyright (C) 1998 Dr. Charles R. Denham, ZYDECO. % All Rights Reserved. % Disclosure without explicit written consent from the % copyright owner does not constitute publication. % Version of 09-Nov-1998 05:37:45. % For Bob Beardsley, WHOI. % 01-Apr-1998 14:22:34. if nargin < 1 help(mfilename) [theFile, thePath] = uigetfile('*.*', 'Select A File:'); if ~any(theFile), return, end infile = [thePath theFile]; end theSuggested = infile; i = find(theSuggested == filesep); if any(i), theSuggested(1:i(length(i))) = []; end i = find(theSuggested == '.'); if any(i), theSuggested(i(length(i)):length(theSuggested)) = []; end theSuggested = [theSuggested '.out']; if nargin < 2 [theFile, thePath] = uiputfile(theSuggested, 'Save File As:'); if ~any(theFile), return, end outfile = [thePath theFile]; end f = fopen(infile, 'r'); if f < 0, return; end g = fopen(outfile, 'w'); if g < 0, fclose(f); return, end while (1) s = fgets(f); if isequal(s, -1), break; end t = upper(s); if any(t >= 'A' & t ~= 'E' & t <= 'Z' & t ~= '*') s = ['% ' s]; end fwrite(g, s); end fclose(f); fclose(g);