www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@cgbrowser/addToFileList.m

    function addToFileList(h,MP)
%ADDTOFILELIST Add a new entry to top of the recent files list
%
%  ADDTOFILELIST(CGB, PROJ) adds the filename associated with the project
%  PROJ to the top of the recently used file list.  The list is trimmed to
%  keep it at the correct maximum length.

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


AP = mbcprefs('mbc');
cgbprefs = getpref(AP,'cgbrowser');

if isempty(cgbprefs.FileList)
    cgbprefs.FileList(1).File = projectfile(MP);
else
    projname = projectfile(MP);
    [pth,~,~] = fileparts(projname);
    if ~strcmp(pth,fullfile(mbcpath,'mbctraining'))
        % don't add mbctraining files to list
        cgbprefs.FileList = [struct('File',projname) cgbprefs.FileList];
        if length(cgbprefs.FileList)>1
            % Remove any duplicate entries
            dups = strcmpi({cgbprefs.FileList(2:end).File},projectfile(MP));
            cgbprefs.FileList(find(dups)+1) = [];
            % Cut to size
            if length(cgbprefs.FileList)>4
                cgbprefs.FileList = cgbprefs.FileList(1:4);
            end
        end
    end
end
setpref(AP,'cgbrowser',cgbprefs);

% update home page and menus
update(h.Hand.HomePage)
h.doDrawMenus;