function [stat,post] = blk2ndord(path,prop,bstr,bint,bflt,parent,name,catalog,ws,node,sbSample)
%BLK2NDORD This block represents a second order differential equation with time-varying
%          coefficients. The coefficients are inputs to the block.
%
% See also BLKINTEG, BLKPIDCON.

% Initial coding by A S Bozin, 6-30-97
% Copyright 1997-2000 The MathWorks, Inc.
% $Revision: 1.4 $ $Date: 2000/06/14 16:08:28 $

   stat = 0;			   		   % Error flag
   nInputs = bint(5);
   nOutputs = bint(6);
   nStates = bint(7);
   %
   % Add mux and demux blocks if necessary
   %
   [post,rect] = blkio('port',nInputs,nOutputs,prop,path);
   %
   % Get the initial conditions
   %
   indStr = bint(17)+1;
   indInt = bint(15)+1;
   npar = 1;
   symInd = zeros(1,npar);				   % Block parameter flags
   str = cell(npar,1);
   mode = bint(indInt);
   if (bitand(mode,8))
      ind = mfindstr(bstr,indStr,'|');
      symInd(npar) = 1;
      str{npar} = bstr(indStr:ind-1);
   end
   indInt = indInt+1;
   nInitX = bint(indInt);
   %
   % Get the block parameter variables
   %
   [symInd,str] = mgetscope(symInd,str,catalog,ws,node);
   if (symInd(npar) == 0)
      x0 = zeros(nStates,1);
      if (nInitX ~= 0)
	 indInt = indInt+nInitX;
	 indFlt = bint(16);
	 iRange = 1:nInitX;
	 x0(bint(indInt+iRange)) = bflt(indFlt+iRange);
      end
      str{npar} = mat2char(x0);
   end

   %
   % SpringMassDamper block (can be continuous or discrete)
   %
   if (any(sbSample))
      bh = add_block('libsb2sl/DYN/DSpringMassDamper',path,...
		     'ForegroundColor',prop.fgColor,...
		     'BackgroundColor',prop.bgColor,...
		     'Orientation',prop.orientation,...
		     'DropShadow',prop.border,...
		     'Position',rect,...
		     'X0',str{1},...
		     'TS',mat2char(sbSample));
   else
      bh = add_block('libsb2sl/DYN/CSpringMassDamper',path,...
		     'ForegroundColor',prop.fgColor,...
		     'BackgroundColor',prop.bgColor,...
		     'Orientation',prop.orientation,...
		     'DropShadow',prop.border,...
		     'Position',rect,...
		     'X0',str{1});
   end
   %
   % Connect the current SpringMassDamper block with the mux and demux blocks
   %
   blkio('line',nInputs,nOutputs,post,parent,name);
   return					   % Last card of BLK2NDORD
