function [stat,post] = blkzp(path,prop,bstr,bint,bflt,parent,name,catalog,ws,node,sbSample)
%BLKZP Defines a system specified by real poles and real zeros.
%
% See also BLKSS, BLKTF, BLKDF.

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

   stat = 0;			   		   % Error flag
   nInputs = bint(5);
   nOutputs = bint(6);
   %
   % Add mux and demux blocks if necessary
   %
   [post,rect] = blkio('port',nInputs,nOutputs,prop,path);
   %
   % Get the zero-pole coefficients as well as the initial output value
   %
   indStr = bint(17)+1;
   indInt = bint(15)+1;
   npar = 4;					   % Number of parameters
   symInd = zeros(1,npar);
   str = cell(npar,1);
   mode = bint(indInt);
   indInt = indInt+1;
   nCoeffs = bint(indInt);
   if (bitand(mode,8))
      ind = mfindstr(bstr,indStr,'|');
      symInd(4) = 1;
      str{4} = bstr(indStr:ind-1);
      indStr = ind+1;
   end
   indInt = indInt+2*nCoeffs;
   indInt = indInt+1;
   if (bitand(mode,16))
      iRange = 1:bint(indInt);
      kRange = bint(indInt+iRange);
      symInd(kRange) = 1;
      for (k = kRange)
	 ind = mfindstr(bstr,indStr,'|');
	 str{k} = bstr(indStr:ind-1);
	 indStr = ind+1;
      end
   end
   %
   % Get the block parameter variables
   %
   [symInd,str] = mgetscope(symInd,str,catalog,ws,node);
   if (symInd(npar) == 0)
      y0 = 0;
      if (nCoeffs ~= 0)
	 indFlt = bint(16);
	 cRange = 1:nCoeffs;
	 y0(cRange) = bflt(indFlt+cRange);
      end
      str{npar} = mat2char(y0);
   end
   indInt = bint(18)+1;
   indInt = bint(indInt)+indInt;		   % Skip icon data
   indFlt = bint(19);
   rDims = ones(3,1);
   cDims = [1;bint(indInt);bint(indInt+1)];
   ub = cumsum(rDims.*cDims);
   lb = [0;ub(1:end-1)]+1;
   for (k = find(~symInd(1:npar-1)))
      coeffs = zeros(rDims(k),cDims(k));
      if (~isempty(coeffs))
	 cRange = lb(k):ub(k);
	 coeffs(:) = bflt(indFlt+cRange);
      end
      str{k} = mat2char(coeffs);
   end
   %
   % Zero-pole block (can be continuous or discrete)
   %
   if (any(sbSample))
      bh = add_block('libsb2sl/DYN/DGainZerosPoles',path,...
		     'ForegroundColor',prop.fgColor,...
		     'BackgroundColor',prop.bgColor,...
		     'Orientation',prop.orientation,...
		     'DropShadow',prop.border,...
		     'Position',rect,...
		     'K',str{1},...
		     'Z',str{3},...
		     'P',str{2},...
		     'Y0',str{4},...
		     'TS',mat2char(sbSample));
   else
      bh = add_block('libsb2sl/DYN/CGainZerosPoles',path,...
		     'ForegroundColor',prop.fgColor,...
		     'BackgroundColor',prop.bgColor,...
		     'Orientation',prop.orientation,...
		     'DropShadow',prop.border,...
		     'Position',rect,...
		     'K',str{1},...
		     'Z',str{3},...
		     'P',str{2},...
		     'Y0',str{4});
   end
   %
   % Connect the current zero-pole block with the mux and demux blocks
   %
   blkio('line',nInputs,nOutputs,post,parent,name);
   return					   % Last card of BLKZP

