function [stat,post] = blkpreload(path,prop,bstr,bint,bflt,parent,name,catalog,ws,node)
%BLKPRELOAD Performs preload or Coulomb switch function.
%
% See also BLKABS, BLKDEADBAND, BLKSATURATION, BLKBNDLIMIT.

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

   stat = 0;			   		   % Error flag
   nInputs = bint(5);
   nOutputs = bint(6);
   %
   % Build mux and demux if necessary
   %
   [post,rect] = blkio('port',nOutputs,nOutputs,prop,path);
   %
   % Get the preload and slope parameters
   %
   indFlt = bint(16);
   indStr = bint(17)+1;
   indInt = bint(15)+1;
   npar = 2;					   % Number of parameters
   symInd = zeros(1,npar);
   mode = bint(indInt);
   if (bitand(mode,16))
      indVar = indInt+2;
      vRange = 1:bint(indVar);
      symInd(bint(indVar+vRange)) = 1;
   end
   ub = [nOutputs;nOutputs+nOutputs];
   lb = [0;nOutputs]+1;
   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);
   for (k = find(~symInd))
      params = zeros(1,nOutputs);
      pRange = lb(k):ub(k);
      params(:) = bflt(indFlt+pRange);
      str{k} = mat2char(params);
   end
   %
   % Preload block
   %
   bh = add_block('libsb2sl/PWL/Preload',path,...
		  'ForegroundColor',prop.fgColor,...
		  'BackgroundColor',prop.bgColor,...
		  'Orientation',prop.orientation,...
		  'DropShadow',prop.border,...
		  'Position',rect,...
		  'preload',str{1},...
		  'slope',str{2});
   %
   % Connect the current block with the mux and demux blocks (if any)
   %
   blkio('line',nOutputs,nOutputs,post,parent,name);
   return					   % Last card of BLKPRELOAD
