function [stat,post] = blkdly(path,prop,bstr,bint,bflt,parent,name,catalog,ws,node,sbSample)
%BLKDLY This block defines a dynamic system that represents a time delay between input
%       and output.
%
% See also BLKINTEG.

% Initial coding by A S Bozin, 6-30-97
% Copyright 1997-2000 The MathWorks, Inc.
% $Revision: 1.8 $ $Date: 2000/08/18 14:58:51 $

   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 block parameter variables
   %
   indStr = bint(17)+1;
   indInt = bint(15)+1;
   mode = bint(indInt);
   npar = 2;					   % Number of parameters
   symInd = zeros(1,npar);
   if (bitand(mode,16))
      indVar = indInt+2;
      vRange = 1:bint(indVar);
      symInd(bint(indVar+vRange)) = 1;
   end
   str = cell(npar,1);
   for (k = find(symInd))
      ind = mfindstr(bstr,indStr,'|');
      str{k} = bstr(indStr:ind-1);
      indStr = ind+1;
   end
   %
   % Get the block parameter variables
   %
   [symInd,str] = mgetscope(symInd,str,catalog,ws,node);
   if (any(~symInd))
      indInt = bint(18)+1;
      indInt = bint(indInt)+indInt;		   % Skip icon data
      indFlt = bint(19);
      rDims = [1;nOutputs];
      cDims = [1;1];
      ub = cumsum(rDims.*cDims);
      lb = [0;ub(1:end-1)]+1;
      for (k = find(~symInd))
	 if ((k == 2) & bitand(mode,1))
	    str{k} = mat2char(zeros(nOutputs,1));
	 else
	    params = zeros(rDims(k),cDims(k));
	    bRange = lb(k):ub(k);
	    params(:) = bflt(indFlt+bRange);
	    str{k} = mat2char(params);
	 end
      end
   end
   %
   % Time delay (can be continuous or discrete)
   %
   if (any(sbSample))
      sbType = catalog(node).type;
      if (bitand(sbType,1792))
	 str{1} = sprintf('%s*%g',str{1},sbSample(1));
      end
      bh = add_block('libsb2sl/DYN/DTimeDelay',path,...
		     'ForegroundColor',prop.fgColor,...
		     'BackgroundColor',prop.bgColor,...
		     'Orientation',prop.orientation,...
		     'DropShadow',prop.border,...
		     'Position',rect,...
		     'TAU',str{1},...
		     'Y0',str{2},...
		     'TS',mat2char(sbSample));
   else
      bh = add_block('built-in/TransportDelay',path,...
		     'ForegroundColor',prop.fgColor,...
		     'BackgroundColor',prop.bgColor,...
		     'Orientation',prop.orientation,...
		     'DropShadow',prop.border,...
		     'Position',rect,...
		     'DelayTime',str{1},...
		     'InitialInput',str{2},...
		     'BufferSize','1024');
   end
   %
   % Connect the current time-delay block with the mux and demux blocks
   %
   blkio('line',nInputs,nOutputs,post,parent,name);
   return					   % Last card of BLKDLY
