function fploopy(y,outp,aporo,header);
%
% function fploopy(y,[outp],[aporo],[header]);
%
% simply does an "fprintf" in order to make an ascii file
%
%    y = some matrix of numbers
% outp = output filename string
% aporo= string 'a' for append (default) or 'o' for overwrite
% header= string header
%
[ry,cy]=size(y);
%
if nargin<2;
outp=input('Enter output filename: ','s');
end;
%
if nargin<3;
  aporo='a';
end;
%
% disp(['please wait while saving ',fid]);
%
%eoutp=exist(outp);
%if eoutp~=0&nargin<3;
%    aporo=input('File Exist. Enter o (overwrite) or a (append): ','s');
%end;
if aporo=='a';
     fid=fopen(outp,'a');
else;
     fid=fopen(outp,'w');
end;

% put header on file if supplied
if nargin==4;
    [nr,nc]=size(header);
    for ii=1:nr;
      fprintf(fid,header(ii,:));
      fprintf(fid,'\n');
    end;
end;



for i=1:ry;
 if cy==1;
   fprintf(fid,'%12.5f\n',y(i));
 elseif cy==2;
   fprintf(fid,'%24.2f %8.2f\n',y(i,1),y(i,2));
%   fprintf(fid,'%12.5f %12.5f\n',y(i,1),y(i,2));
 else
%
% different process for odd vs even # of columns
%
% First, the even case
%
   if rem(cy,2)==0;
    for ir=1:2:cy-1;
     if ir~=cy-1;
       fprintf(fid,'%12.3f %12.3f',y(i,ir),y(i,ir+1));
%      if ir==1;fprintf(fid,'<tr>');end;
%      fprintf(fid,'<td>%11.2e</td><td>%11.2e</td>',y(i,ir),y(i,ir+1));
     else
       fprintf(fid,'%10.4f %9.3f\n',y(i,ir),y(i,ir+1));
%      fprintf(fid,'<td>%11.2e</td><td>%11.2e</td></tr>\n',y(i,ir),y(i,ir+1));
     end;
    end;
   else;
%
% Now, the odd case
%
     for ir=1:2:cy;
      if ir~=cy;
       fprintf(fid,'%10.4f %10.4f',y(i,ir),y(i,ir+1));
      else
       fprintf(fid,'%10.4f\n',y(i,ir));
      end;
     end;
    end;
  end;
end;
fclose(fid);