function hConvertStringPolysToNum(blk, polyParamName, outfmt, varargin)
%

%   Copyright 2015-2021 The MathWorks, Inc.

    % convert string polynomials (e.g., '1+X+X^3') to equivalent numeric
    % representations that are understood in pre-R2015b releases
    
    poly   = get_param(blk, polyParamName);    
    
    if length(poly) >= 2 && poly(1)   == '''' && poly(end) == '''' 
        % genPoly is a string
        
        % remove string quotes (start and end of strings):
        poly(  poly  == '''') = '';
        
        if nargin == 3
            % general polynomial string e.g., 'X^3 + X + 1' or '3*X2 + 2*X + 2'
            poly  = commstr2poly(poly,  outfmt);
        else
            % Reed-Solomon: Possibly exponential-form polynomial string, e.g., 'a^3*X2 + a^2'
            % varargin{1} contains the primitive polynomial
            parseAlpha = true;
            % eval because it may be a function call such as int2bit:
            primPoly = evalin('base', varargin{1}); 
            poly  = commstr2poly(poly,  outfmt, primPoly, parseAlpha);
        end
        set_param(blk, polyParamName, [ '[' num2str(poly) ']' ]);
    end
end
