function ident(sessname,pathname)
%IDENT	Starts the Graphical User Interface for the System Identification Toolbox.
%
%	ident   or  ident(SESSION,PATH)
%	
%       IDENT by itself opens the main interface window.
%       SESSION is a SITB session file (typically with extension .sid)
%       PATH is the search path for this file. (Not necessary if on the
%	MATHLABPATH.) When SESSION is specified, the interface opens
%	with this session.
%	
%	When the interface is active, ident(SESSION,PATH) will open the
%	session SESSION.
 
%	L. Ljung 4-4-94
%	Copyright (c) 1986-95 by the MathWorks, Inc.
%	$Revision: 1.7 $  $Date: 1995/05/24 11:52:45 $


global XIDlayout XIDsumb XIDcounters XIDsessions XIDlaypath XIDplotprefs
global XIDstyleprefs
XIDmain_win=findobj(get(0,'children'),'flat','tag','sitb16');

if isempty(XIDmain_win)
   fprintf('Opening ident .')
   if exist('idprefs.mat')
      load idprefs
      [nr,nc]=size(XIDsessions);
      if nr<8
         XIDsessions=str2mat('iddata1.sid','','iddata7.sid','',...
                          'dryer.sid','','steam.sid','');
      end
   else
      XIDlaypath=which('startup');
      XIDlayout=[];XIDstyleprefs=[];XIDplotprefs=[];
      XIDsessions=str2mat('iddata1.sid','','iddata7.sid','',...
                          'dryer.sid','','steam.sid','');
      err=0;
      lx=length(XIDlaypath);
      if lx<10
         err=1; XIDlaypath=[];
      else
       XIDlaypath=XIDlaypath(1:lx-9);
       eval(['save ',XIDlaypath,...
           'idprefs.mat XIDlaypath XIDsessions XIDlayout ',...
           'XIDstyleprefs XIDplotprefs'],'err=1;')
       testlay=exist('idprefs.mat');
       if ~testlay&~err,err=1;eval(['delete ',XIDlaypath,'idprefs.mat']);end
      end
      if err==0
          wtext=str2mat('',['Created preference file ',...
               XIDlaypath,'idprefs.mat.'],...
              'Type HELP MIDPREFS if you want to move this file.');
          disp(wtext)
      else
         wtext=str2mat('',...
               'Warning: Could not find idprefs.mat and could not create',...
               '         PrefDir/idprefs.mat',...
               ['You may ignore this warning or type HELP',...
               ' MIDPREFS for your options.']);
         disp(wtext)
      end
   end
   eval('sumboard;')
   eval('idmwwb(1);iduidrop;')
   zzz=rand(100,2);
   tic,arx(zzz,[4 4 1]);t=toc;  
   XIDcounters(6)=t/2;
else 
   figure(XIDmain_win)
end
   if nargin>0
    if nargin<3,pathname='';end
    eval('iduisess(''load'',pathname,sessname);')
   end
