function varargout = pp(varargin)
%   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.                                                                      

% -----------------------------------------
% Startfenster für diverse Anwendungen
% -----------------------------------------

%------------------------------------------
% mode: 0  : not selected
% 		  11 : batchmode directory
%		  12 : batchmode batchfile
%		  2  : singelfilemode
%
%------------------------------------------

if nargin == 0  % LAUNCH GUI
    
    % Variablen initialisieren
	%-------------------------
	global faktorstring stufenvec gradientcell aktiverfaktor ...
        rauschslider amount anzahlsegmente segmentedit alignwindow...
        channelgroupedit movieedit zeitpunkteedit subjecttedit...
        transposewindow bwritescewindow blockradio pauseradio ...
        stimulilist designlist blockradio countdownradio ...
        neutralsradio pauseradio prestimeedit extensionedit...
        mode
    
	%figure
	%--------------
	fig = openfig('ppfig.fig','new');
	handles = guihandles(fig);
	guidata(fig, handles);
	faktorstring=cell(1,1);
	faktorstring=zeros(3,1);
	filepath = '';
	filename = '';
	vorgang='';
	startformat='';
	endformat='';
	mode=0;
    
	if nargout > 0
		varargout{1} = fig;
	end

elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
    global faktorstring stufenvec gradientcell aktiverfaktor ...
        rauschslider amount anzahlsegmente segmentedit alignwindow...
        channelgroupedit movieedit zeitpunkteedit subjecttedit...
        transposewindow bwritescewindow blockradio pauseradio ...
        stimulilist designlist blockradio countdownradio ...
        neutralsradio pauseradio prestimeedit extensionedit mode filename filepath
	try
		if (nargout)
            evalstring='[varargout{1:nargout}] = feval(varargin{1}';
            for j=2:nargin
                if ~isnumeric(varargin{j}) & exist(varargin{j})==1
                    evalstring=[evalstring,',eval(varargin{',num2str(j),'})'];
                elseif isstr(varargin{j})
                    evalstring=[evalstring,',varargin{',num2str(j),'}'];
                elseif isnumeric(varargin{j})
                    evalstring=[evalstring,',',num2str(varargin{j})];
                end
            end
            evalstring=[evalstring,');'];
            eval(evalstring);
            
            for i=2:nargout
                if ~isstr(varargout{i})
                    eval([varargout{1}{i-1},'=',num2str(varargout{i}),';']);
                else
                    eval([varargout{1}{i-1},'=',char(39),num2str(varargout{i}),char(39),';']);
                end
            end
            
		else
            evalstring='feval(varargin{1}';
            for j=2:nargin
                if ~isnumeric(varargin{j}) & exist(varargin{j})==1
                    evalstring=[evalstring,',eval(varargin{',num2str(j),'})'];
                elseif isstr(varargin{j})
                    evalstring=[evalstring,',varargin{',num2str(j),'}'];
                elseif isnumeric(varargin{j})
                    evalstring=[evalstring,',',num2str(varargin{j})];
                end
            end
            evalstring=[evalstring,');'];
            eval(evalstring);
            
		end
        
        
	catch
		disp(lasterr);
	end

end
return