Code covered by the BSD License  

Highlights from
find lines of code which are not suppressed (no semicolon at end)

find lines of code which are not suppressed (no semicolon at end)


Ueli Rutishauser


Finds code that generates output in the command window due to a missing semicolon (non-suppressed)

findNonSuppressedOutput( p, considerPath )
function findNonSuppressedOutput( p, considerPath )
% finds, based on profile data, lines of code which produce non-suppressed output
% (not terminated by semicolon). Useful to find annoying output in large programs
% consisting of many files. Only functions which are actually called are considered.
% to use:
% profile on; YourFunct(a,b,c); profile off;
% p=profile('info');
% findNonSuppressedOutput( p, '/code/projectA/' )
% this will run mlint on all called functions in path /code/projectA/ (and subdirs)
% and report lines that contain the requested mlint IDs (here: non-terminated lines)
% functions called that reside outside the provided path are ignored.
%April 2009, ueli rutishauser,

IDsToCatch = { 'NOPRT', 'NOPTS' }; %list of mlint IDs to find in all functions called

funcTable = p(1).FunctionTable;

disp('Files that have entries that dont supress output:');
for k=n:-1:1   
    fName = funcTable(k).FileName;
    if ~isempty( strfind( fName, considerPath))       
        mInfo = mlint( fName, '-id' );        
        for j=1:length(mInfo)  %go through each mlint entry to find wanted ID
            if sum(strcmp( mInfo(j).id, IDsToCatch ))>0
                lNrStr = num2str(mInfo(j).line);
                cmdStr = ['<a href="matlab: opentoline(''' fName ''',' lNrStr ',1)">' lNrStr '</a>'];                
                disp([cmdStr ' F: ' fName ' M:' mInfo(j).message ]);

Contact us