function batchresults  = filterBatchresults(batchresults,varargin)


%args = size(varargin,2)/2;
args = size(varargin,2);

i = 0;
while true
    i = i + 1;
    column = varargin(i);
    if i == args
        batchresults  = extractInfoFromBatchresults(batchresults,column);
        break
    elseif i > args
        break
    else
        i = i +1;
        if strcmp(upper(varargin(i)),'VALUE') || strcmp(upper(varargin(i)),'RELOP');
            if strcmp(upper(varargin(i)),'VALUE')
                i = i + 1;
                aValue = varargin(i);
                i = i + 1;
                if ischar(varargin(i))
                    if strcmp(upper(varargin(i)),'RELOP')
                        i = i + 1;
                        RelOp = varargin(i);
                        batchresults  = extractInfoFromBatchresults(batchresults,column,RelOp,aValue);
                    else
                        error('WARN administrator: programming error')
                    end
                else
                    i = i - 1;
                    batchresults  = extractInfoFromBatchresults(batchresults,column,'==',aValue);
                end
            else
                relOp = varargin(i);
                i = i + 1;
                if ischar(varargin(i))
                    if strcmp(upper(varargin(i)),'VALUE')
                        i = i + 1;
                        aValue = varargin(i);
                        batchresults  = extractInfoFromBatchresults(batchresults,column,RelOp,aValue);
                    end
                else
                    error('WARN administrator: programming error')
                end
            end
        else
            error('WARN administrator: programming error')
        end
    end
    if restargs == -1
        batchresults  = extractInfoFromBatchresults(batchresults,varargin{i*2-1});
        break
    else
        batchresults  = extractInfoFromBatchresults(batchresults,varargin{i*2-1},varargin{i*2});
        if restargs == 0
            break
        end
    end    
end    
    
%for i = 1:args:2
%    restargs = args-(i-1)*2+1;
%    batchresults  = extractInfoFromBatchresults(batchresults,varargin{i*2-1},varargin{i*2});
%end