%% check_grid_result
%   Similar to above function check_grid_result, will loop through
% the cells of the output grid, unline check_grid, does not need to
% recurse.
% inputs:
%   object:GUI - current GUI object
%   grid:RGrid - RGrid object to be checked
% outputs:
%   none
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function msg = check_grid_result(object,grid)
msg = [];
for i = 1:grid.width
    for j = 1:grid.height
        string = grid.get_cell(j, i).get_matlab_string();


        error = object.check_matlab_syntax_condition(char(string),1);
        if isempty(error)
            if (strcmp(string,'') || isempty(string))
                error = 'Cell is empty';
            end
        end
        if ~isempty(error)
            msg = [msg sprintf('\n')];

            msg = [msg 'Result -> ' char(string) sprintf('\n')];
            msg = [msg error sprintf('\n')];

            % TODO Re-enable!
            %set(grid.Cells(i).result,'TooltipString',error);
            %grid.Cells(i).flag_cell(1);
        else
            %set(grid.Cells(i).result,'TooltipString','');
            %grid.Cells(i).flag_cell(0);
        end
    end
end
end

