www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevproject/close.m

    function [MP,msg,cancel]= close(MP,force,LastNode)
%CLOSE Close the project
%
%  [P, MSG] = CLOSE(P, FORCEFLAG,LASTNODE) closes the project P.  This will save the
%  project if required and remove the temporary lock file.  FORCEFLAG is an
%  optional flag that forces a save without asking the user whether they
%  want to.

%  Copyright 2000-2016 The MathWorks, Inc. and Ford Global Technologies, Inc.


if nargin<2
    force= 0;
end
if nargin<3
    LastNode = [];
end

msg='';
cancel = false;
[path,~,~]= fileparts(MP.Filename);

if force
    [MP,msg] = save(MP,0);
elseif MP.Modified && ~(isBlank(MP) || strcmp(path,fullfile(mbcpath,'mbctraining')))% needs saving
    [~,filenm] = fileparts(MP.Filename);
    answer = questdlg(['Do you want to save the changes you made to "',filenm,'"?'],'Save Project','Yes');
    drawnow
    switch answer
        case 'Yes'
            [MP,msg] = save(MP,0,LastNode);
            MP.Modified = 0;
            pointer(MP);
        case {'Cancel', ''}
            cancel = true;
            msg = 'Close cancelled';
            return
    end
end

% delete temp file
[P,F]= fileparts(MP.Filename);
if ~isempty(P) && exist([P,filesep,'~',F,'_xreg.tmp'], 'file')
    recycle_state = recycle('off');
    delete([P,filesep,'~',F,'_xreg.tmp']);
    recycle( recycle_state );
end