www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/cgbstart.m

    function cgbstart(file)
%CGBSTART Start an initialised CAGE Browser session
%
%  CGBSTART starts up the cage browser.
%  CGBSTART(FILE) starts up the browser and loads FILE.

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


loaddefault = true;
addtolist = false;

if nargin
    [p,f] = fileparts(file);
    if isempty(p)
        file = which(file);  % retrieve full pathname
    end
    if isempty(file)
        warning(message('mbc:cgbstart:FileNotFound', f));
    else
        %Load a file
        prj = cgproject;
        [prj,msg] = load(prj,file,1,1);
        if ~isempty(msg) || isempty(prj) % error, or empty project
            if ~isempty(prj)
                freeptr(address(prj));
            end
            if ~isempty( msg )
                warning(message('mbc:cgbstart:FileLoadProblem', file, msg));
            else
                warning(message('mbc:cgbstart:FileLoadProblem1', file));
            end
        else
            if strcmp(projectfile(prj),file)
                % If we have a filename and it wasn't changed by the load procedure,
                % we will add it to the recently-used file list.
                addtolist = true;
            end
            loaddefault = false;
        end
    end
end

if loaddefault
    % No file loaded.  Load up a new one called "Untitled"
    prj = info(cgcreateproject(mbcGetPath('cage', 'Projects', 'Untitled')));
    prj = setmodified(prj,1);
end

cgb = cgbrowser;
cgb.show(address(prj));
mbcutils.GenericTableProvider.Instance.addTableProvider(cgtools.CageTableProvider(address(prj)));

if addtolist
    % this has to be done last
    cgb.addToFileList(prj);
end