function [FilterSet,Error,next] = getNextFilterSet(pointer,varargin)

args   = varargin{1};
nrArgs = length(args);

next = pointer;
if next > nrArgs %no filter set
    FilterSet.Nr = 0;
    next = -1;
    Error.Code = 0;
    Error.Message = 'No error';
    return
end

arg = args{next};
if ~isAnInteger(arg)
    FilterSet.Nr = -1;
    Error.Code = 1;
    Error.Message = 'WARN ADMINISTRATOR. The column # must be an integer';
    error(Error.Message)
else
    FilterSet.Nr = arg;
end

next = next + 1;
if next > nrArgs
    FilterSet.RelOp = 'none'; %select the whole column
    Error.Code = 0;
    Error.Message = 'No error';
    next = -1;
    return
end

[type,out,next,Error] = getNextFilterOperand('free','needed',next,args);
if Error.Code == 0
    if strcmp(upper(type),'VALUE')
        FilterSet.Value = out;
        [type,out,next,Error] = getNextFilterOperand('relop','free',next,args);
        if Error.Code ~= 0
            error(Error.Message)
        end
        FilterSet.RelOp = out;
    elseif strcmp(upper(type),'RELOP')
        FilterSet.RelOp = out;
        [type,out,next,Error] = getNextFilterOperand('value','needed',next,args);
        if Error.Code ~= 0
            error(Error.Message)
        end
        FilterSet.Value = out;
    end
else
    error(Error.Message)
end    
