function outvalue = stealparameter( curBlock, paramNameStr, invalue );
% STEALPARAMETER used in Fixed Point Autoscaling to get parameters
%   values hidden under one or more layers of masks.
%
%    See also AUTOFIXEXP.

% Copyright 1994-2002 The MathWorks, Inc.
% $Revision: 1.10.4.1 $  
% $Date: 2004/11/21 20:33:34 $

outvalue = invalue;

global FixPtTempGlobal

len = length(FixPtTempGlobal);

iFound = 0;

for i=1:len
    if strcmp(FixPtTempGlobal{i}.Path, curBlock )

      FixPtTempGlobal{i} = setfield(FixPtTempGlobal{i},'Parameters',paramNameStr,'paramValue',invalue);
    
      iFound = i;
      break;
    end
end

if iFound == 0

  if ~strcmp(strtok(curBlock,'/'),bdroot)
    error('SimulinkFixedPoint:stealparameter:wrongbdroot',...
          ['The Simulink model %s contains corrupt Fixed-Point autoscaling ' ... 
           'instrumentation.  The instrumentation specifies a different ' ...
           'model.  At the MATLAB command prompt, run the function ' ...
           'fixpt_instrument_purge to remove the corrupt instrumentation.'], ...
          bdroot);
  end
  
  FixPtTempGlobal{end+1}.Path = curBlock;

  FixPtTempGlobal{end} = setfield(FixPtTempGlobal{end},'Parameters',paramNameStr,'paramValue',invalue);
end
