function wavelet2fftmanage(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.                                                                      

if mode==0
   modefehler
   return

% directory mode   
elseif mode==11
	cd (filepath);
	filelist=dir(filepath);
    filelistsize=size(filelist);
    ModDataMatcell=cell(1);
	% Schleife für Files
   for filezaehler=3:filelistsize(1)
      ModDataMatcell{filezaehler-2}=wavelet2fft(filelist(filezaehler).name);
   end
    savestatus = questdlg('Do you wish to save data as mat-file or as ascii-file? ','mat','ascii','ascii');
   if ~strcmp(savestatus,'ascii')
       writewavelet2fft(ModDataMatcell);
   else
       [savefilename,savefilepath]=uiputfile('*.mat','Please name result-mat-file:');
        save([savefilepath,savefilename],'ModDataMatcell');
    end
    ok
   
% batchfile mode   
elseif mode==12
   filemat=batchfiletomat(filename,filepath);
   filematgroessevec=size(filemat);
   filematgroesse=filematgroessevec(2);
   ModDataMatcell=cell(1);
   for l=1:filematgroesse
      ModDataMatcell{l}=wavelet2fft(filemat{l});
   end
   savestatus = questdlg('Do you wish to save data as mat-file or as ascii-file? ','mat','ascii','ascii');
   if ~strcmp(savestatus,'ascii')
       writewavelet2fft(ModDataMatcell);
   else
       [savefilename,savefilepath]=uiputfile('*.mat','Please name result-mat-file:');
        save([savefilepath,savefilename],'ModDataMatcell');
    end
    ok
      
% single file mode   
elseif mode==2
   ModDataMatcell=cell(1);
   ModDataMatcell=wavelet2fft(filename,filepath);
    savestatus = questdlg('Do you wish to save data as mat-file or as ascii-file? ','mat','ascii','ascii');
   if ~strcmp(savestatus,'ascii')
       
       writewavelet2fft(ModDataMatcell);
   else
       [savefilename,savefilepath]=uiputfile('*.mat','Please name result-mat-file:');
        save([savefilepath,savefilename],'ModDataMatcell');
    end
    ok
  
end
return