function varargout = errordlgMLS(varargin)
%errordlgMLS error message
%   varargout = errordlgMLS(varargin) shows an error message with the
%   IMPACT icon. If there already exists one, the new error will be added to it

%   Project: IMPACT
%   Title of Code: errordlgMLS
%   Relevant additional documentation:
%   Developer: Carlos Gonzalez
%   External Dependencies: NA
%
%   Disclaimer
%   CAUTION: It is strongly recommended that changes to this code
%   should be avoided without first consulting with authors


% to check if there is already an error dialog 
old_dlg = findall(0,'tag', 'Msgbox_Error Dialog');

if ~isempty(old_dlg) && nargin > 0
    text_h = findall(old_dlg(1), 'type', 'text');   
    str = get(text_h, 'String');
    if ~isempty(str)
        varargin{1} = [str{:}, varargin{1}];
    end   
    close(old_dlg(1));
end
if nargout
    [varargout{1:nargout}] = errDlgLogo(varargin{:});
else errDlgLogo(varargin{:});
end


function varargout = errDlgLogo(varargin)
if nargout
    [varargout{1:nargout}] = errordlg(varargin{:});
    hMLS = varargout{1};
else hMLS = errordlg(varargin{:});
end

addIMPACTIcon(hMLS);

set(hMLS, 'WindowStyle', 'modal');






