function pparamanage(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;


% kein file gewählt
if mode==0
   modefehler
   return
   
   
% directory mode   
elseif mode==11
    [savefilename,savefilepath]=uiputfile('*.txt','Ergebnisfile bestimmen:');
    savefile=[savefilepath savefilename];
    savefilehandle=fopen(savefile,'wt');
    fprintf(savefilehandle,['filename\ttot_bright\ttot_cont\tred_bright\tred_cont\tgreen_bright\tgreen_cont\tblue_bright\tblue_cont\tminb\tmaxb\n']);
	cd (filepath);
	filelist=dir(filepath);
   filelistsize=size(filelist);
      
	% Schleife für Files
   for filezaehler=3:filelistsize(1)
      filename=filelist(filezaehler).name;
      [bildnummer,totbright,totcont,redbright,redcont,greenbright,greencont,bluebright,bluecont,minb,maxb]=ppara(filename,filepath);
 	  fprintf(savefilehandle,[filename,'\t',num2str(totbright),'\t',num2str(totcont),'\t',num2str(redbright),'\t',num2str(redcont),'\t',num2str(greenbright),'\t',num2str(greencont),'\t',num2str(bluebright),'\t',num2str(bluecont),'\t',num2str(minb),'\t',num2str(maxb),'\n']);
   end
   fclose(savefilehandle);
   ok
   return
     
% batchfile mode   
elseif mode==12
   [savefilename,savefilepath]=uiputfile('*.txt','Ergebnisfile bestimmen:');
   savefile=[savefilepath savefilename];
   savefilehandle=fopen(savefile,'wt');
   fprintf(savefilehandle,['filename\ttot_bright\ttot_cont\tred_bright\tred_cont\tgreen_bright\tgreen_cont\tblue_bright\tblue_cont\tminb\tmaxb\n']); 
   filemat=batchfiletomat(filename,filepath);
   filematgroessevec=size(filemat);
   filematgroesse=filematgroessevec(2);
   for l=1:filematgroesse
      [bildnummer,totbright,totcont,redbright,redcont,greenbright,greencont,bluebright,bluecont,minb,maxb]=ppara(filemat{l});
     
     fprintf(savefilehandle,[bildnummer,'\t',num2str(totbright),'\t',num2str(totcont),'\t',num2str(redbright),'\t',num2str(redcont),'\t',num2str(greenbright),'\t',num2str(greencont),'\t',num2str(bluebright),'\t',num2str(bluecont),'\t',num2str(minb),'\t',num2str(maxb),'\n']);
   end
   fclose(savefilehandle);
   return
   
      
% single file mode   
elseif mode==2
   [bildnummer,totbright,totcont,redbright,redcont,greenbright,greencont,bluebright,bluecont,minb,maxb]=ppara(filename,filepath)
   ok
end



return