function notUsed = dsp_cgArgNotUsed(param, xargs)
% notUsed = dsp_cgArgNotUsed(param, xargs)
%  Tests to see if param should be exlcuded from an argument list.
%  If the param is not found in the xArgs exlcusion list then
%  the functino will return false; otherwise it will return true. 

% Author: J. Faneuff
% Copyright 1995-2000 The MathWorks, Inc.
% $Revision: 1.2 $ $Date: 2000/05/05 20:16:20 $

% TEST DATA
% xargs   = 'u1, u2, nChans';
% param1 = 'u1';
% param2 = 'u';
% param3 = '*u2';

% Assume param is NOT on the exclude list
notUsed = 0;

idx = findstr(param, xargs);
plen = length(param);
xlen = length(xargs);

if ~isempty(idx)
    
    % Loop over number of string matches we find
    for i = 1:length(idx)
        
         % Look for preceding comma/space
        if idx(i) == 1  % Protect against idx-1 == 0
            pc = 1;     % String is param if it is first char in xargs
        else
            pc = (isspace(xargs(idx(i)-1)) | xargs(idx(i)-1) == ',');
        end
        
        % Look for trailing comma/space     
        if idx(i)+plen > xlen  % Protect against idx+plen > xlen
            tc = 1;            % String is param if it is last in xargs
        else
            tc = (isspace(xargs(idx(i)+plen)) | xargs(idx(i)+plen) == ',');
        end
        
        if pc & tc;
        	notUsed = 1;   % Param is on exclude list
            break;             % Stop for loop because we have a match
        end
    end
end

% [EOF] dsp_cgArgNotUsed
