function sparamanage(filename,filepath,mode)
%  

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.                                                                      
filezaehler=0;
[savefilename,savefilepath]=uiputfile('*.txt','Ergebnisfile bestimmen:');
savefile=[savefilepath savefilename];
savefilehandle=fopen(savefile,'at');
fprintf(savefilehandle,['filename\tPeakamplitude\t\tGesamtleistung:\tVarianz:\n']);
fprintf(1,['filename\tPeakamplitude\t\tGesamtleistung:\tVarianz:\n']);
% kein file gewählt
if mode==0
   modefehler
   fclose(savefilehandle);
   return
   
   
% directory mode   
elseif mode==11
	cd (filepath);
	filelist=dir(filepath);
   filelistsize=size(filelist);
      
	% Schleife für Files
   for filezaehler=3:filelistsize(1)
      filename=filelist(filezaehler).name;
      [peakamplitude,gesamtleistung,varianz]=spara(filename,filepath);
 		fprintf(savefilehandle,[filename,'\t',num2str(peakamplitude),'\t',num2str(gesamtleistung),'\t',num2str(varianz),'\n']);
   end
   fclose(savefilehandle);
   ok
     
% batchfile mode   
elseif mode==12
    
     filemat=batchfiletomat(filename,filepath);
   filematgroessevec=size(filemat);
   filematgroesse=filematgroessevec(2);
   for l=1:filematgroesse
       
      [peakamplitude,gesamtleistung,varianz]=spara(filemat{l});
      fprintf(savefilehandle,'%s',filemat{l});
      fprintf(savefilehandle,'\t');
      fprintf(savefilehandle,'\t',[num2str(peakamplitude),'\t',num2str(gesamtleistung),'\t',num2str(varianz),'\n']);
      fprintf(1,'%s',[filemat{l}]);
      fprintf(1,'\t');
      fprintf(1,[num2str(peakamplitude),'\t',num2str(gesamtleistung),'\t',num2str(varianz),'\n']);
   end
   fclose(savefilehandle);
   return
      
% single file mode   
elseif mode==2
   [peakamplitude,gesamtleistung,varianz]=spara(filename,filepath);
   fprintf(savefilehandle,[filename,'\t',num2str(peakamplitude),'\t',num2str(gesamtleistung),'\n']);
   fclose(savefilehandle);
   ok
end



return