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

    function MBstart(file)
%MBSTART Start an initialised MBrowser session
%
%  MBSTART starts up the model browser.
%  MBSTART(FILE) starts up the browser and loads FILE.

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


addtolist = false;
loaddefault = true;

if nargin
    % Try to load a file
    [p,f] = fileparts(file);
    if isempty(p)
        file = which(file);  % retrieve full pathname
    end
    if isempty(file)
        warning(message('mbc:mbstart:FileNotFound', f));
    else
        MP = mdevproject;
        [MP,msg] = load(MP,file);
        if ~isempty(msg) && ~isempty(strfind(msg,'MATLAB:loadobj'))
            % remove hyperlink lines.
            pos = strfind(msg,'</a>');
            if ~isempty(pos)
                msg = msg(pos(end)+4:end);
            end
        end
        if ~isempty( msg ) || isempty(MP)
            if ~isempty(msg)
                error(message('mbc:mbstart:FileLoadProblem', file, msg));
            else
                error(message('mbc:mbstart:FileLoadProblem1', file));
            end
        else
            loaddefault = false;
            addtolist = true;
            % set up with last node 
            StartNode = getLastNode(MP);
            if isempty(StartNode) || ~isvalid(StartNode)
                StartNode = address(MP);
            end

        end
    end
end

if loaddefault
    MP = mdevproject(mbcGetPath('mbcmodel', 'Projects', 'Untitled'),[],[]);
    StartNode = address(MP);
end

mbH = MBrowser;
mbH.Show(address(MP));
if ~loaddefault
    % select start node
    mbH.SelectNode(StartNode);
end


if addtolist
    mbH.addToFileList(MP);
end