www.gusucode.com > rptgen 工具箱matlab源码程序 > rptgen/rptlist.m

    function varargout=rptlist(varargin)
%RPTLIST returns a list of all .rpt files on the path
%   LIST=RPTLIST returns a list of all .rpt files on
%   the MATLAB path.
%
%   RPTLIST by itself opens the Report Generator editor with a
%   list of all available setup files.  These files can be opened,
%   run, or associated with the current Simulink system.
%
%   RPTLIST('system_name') starts the GUI with the Simulink system's
%   "ReportName" property selected.
%
%   See also: SETEDIT, REPORT, RPTCONVERT, COMPWIZ

%   Copyright 1997-2012 The MathWorks, Inc.


if nargin<1
    if nargout<1
        viewChild(RptgenML.Root);
    else
        varargout{1}=LocGetFileList;
    end
else
    
    if(isa(varargin{1}, 'Stateflow.Chart'))
        varargin{1} = varargin{1}.Machine.Name;
        
    elseif (~ischar(varargin{1}) && ~ishandle(varargin{1}))
        
        error(message('rptgen:rptgenrptgen:invalidTypeForRptlist', class(varargin{1})));
        
    end
    
    
    if nargin>1
        isImmediateGenerate=strcmpi(varargin{2},'-generatereport');
    else
        isImmediateGenerate=false;
    end
    
    if isImmediateGenerate
        rptName = cbkReport(RptgenML.Root,varargin{1});
        %this handles simulink properly
    else
        rptName = viewChild(RptgenML.Root,varargin{1});
        %this handles simulink properly
    end
    
    if nargout>0
        varargout{1}=rptName;
    end
    
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function  rptFileList=LocGetFileList
%construct the list of .rpt files

StopSearchValue(false);

pSep=pathsep;

if isempty(strfind(lower(path), lower(pwd)));
    pathString=[pSep pwd pSep path pSep];
else
    pathString=[pSep path pSep];
end

breakIndex=strfind(pathString,pSep);

rptFileList={};
lastIndex=length(breakIndex)-1;
i=1;
while i<=lastIndex && ~StopSearchValue
    myDir=pathString(breakIndex(i)+1:breakIndex(i+1)-1);
    fileList=dir([myDir filesep '*.rpt']);
    if ~isempty(fileList)
        allFiles={fileList.name};
        rptFileList=[rptFileList;...
            strcat([myDir filesep],allFiles(:))]; %#ok<AGROW>
    end
    i=i+1;
end

%include custom file names
rptFileList=[rptFileList StoreCustomNames];


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout=StoreCustomNames(varargin)
%customList=StoreCustomNames
%     returns the list of stored custom names
%StoreCustomNames(rpt1,rpt2,....)
%     adds input setup file names to the list
%     of stored custom names

persistent RPTGEN_RPTLIST_CUSTOM_SETUP_FILES

if ~iscell(RPTGEN_RPTLIST_CUSTOM_SETUP_FILES)
    RPTGEN_RPTLIST_CUSTOM_SETUP_FILES={};
end

if nargin>0
    RPTGEN_RPTLIST_CUSTOM_SETUP_FILES=...
        [RPTGEN_RPTLIST_CUSTOM_SETUP_FILES
        varargin'];
end

if nargout>0
    varargout{1}=RPTGEN_RPTLIST_CUSTOM_SETUP_FILES;
end


%%%%%%%%%%%%%%%%%%%%%%%%
function stopVal=StopSearchValue(stopVal)

persistent RPTGEN_STOP_RPTLIST_SEARCH

if nargin>0
   RPTGEN_STOP_RPTLIST_SEARCH=stopVal;
end

stopVal=RPTGEN_STOP_RPTLIST_SEARCH;