Commit d14ea6dd authored by Colin Eles's avatar Colin Eles
Browse files

added a utility file for checking for unsuppressed output, ie stuff that will...

added a utility file for checking for unsuppressed output, ie stuff that will print to the command window. thinking of putting it on file exchange because its fairly useful

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/trunk/TableTool@6619 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 8ba37e16
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@
% the default save option so if the "Save" button is pressed it will
% perform this action.
%
% If changes are made in the table interface they will not be updated in
% If changes are made in the table interface they will not be updated in the
% underlying generated code in
% the simulink block until saving is performed, it is important to remember
% to save before closing the interface.
%
+4 −3
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
   <!--
This HTML is auto-generated from an M-file.
To make changes, update the M-file and republish this document.
      --><title>Saving a Table</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-11-30"><meta name="m-file" content="TT_ug_saving"><style type="text/css">
      --><title>Saving a Table</title><meta name="generator" content="MATLAB 7.10"><meta name="date" content="2010-12-01"><meta name="m-file" content="TT_ug_saving"><style type="text/css">

body {
  background-color: white;
@@ -62,7 +62,7 @@ p.footer {
  color: gray;
}

  </style></head><body><div class="content"><h1>Saving a Table</h1><!--introduction--><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Saving to Block</a></li><li><a href="#2">Saving to an M-File</a></li></ul></div><h2>Saving to Block<a name="1"></a></h2><p>Saving to a block will either save to an existing simulink block or create a new simulink block for the current table. Saving to a block is the default save option so if the "Save" button is pressed it will perform this action.</p><p>If changes are made in the table interface they will not be updated in the simulink block until saving is performed, it is important to remember to save before closing the interface.</p><h2>Saving to an M-File<a name="2"></a></h2><p>The Table Toolbox allows for users to save their table as an m-function. This allows the function to be called from Matlab scripts or functions; users can also run the function from the command line as a quick way of testing functionality.</p><p>To save a table to an m-file select the "save to m-file" command from the file menu as seen in the following screen shot.</p><p><img vspace="5" hspace="5" src="ug_save_1.png" alt=""> </p><p>The toolbox will create a file with the name expression_name.m, where expression_name is the name of your expression. The function can then be called as you would any other function in Matlab, ie. expression_name(arg1,arg2,...)</p><p class="footer"><br>
  </style></head><body><div class="content"><h1>Saving a Table</h1><!--introduction--><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Saving to Block</a></li><li><a href="#2">Saving to an M-File</a></li></ul></div><h2>Saving to Block<a name="1"></a></h2><p>Saving to a block will either save to an existing simulink block or create a new simulink block for the current table. Saving to a block is the default save option so if the "Save" button is pressed it will perform this action.</p><p>If changes are made in the table interface they will not be updated in the underlying generated code in the simulink block until saving is performed, it is important to remember to save before closing the interface.</p><h2>Saving to an M-File<a name="2"></a></h2><p>The Table Toolbox allows for users to save their table as an m-function. This allows the function to be called from Matlab scripts or functions; users can also run the function from the command line as a quick way of testing functionality.</p><p>To save a table to an m-file select the "save to m-file" command from the file menu as seen in the following screen shot.</p><p><img vspace="5" hspace="5" src="ug_save_1.png" alt=""> </p><p>The toolbox will create a file with the name expression_name.m, where expression_name is the name of your expression. The function can then be called as you would any other function in Matlab, ie. expression_name(arg1,arg2,...)</p><p class="footer"><br>
      Published with MATLAB&reg; 7.10<br></p></div><!--
##### SOURCE BEGIN #####
%% Saving a Table
@@ -74,7 +74,8 @@ p.footer {
% the default save option so if the "Save" button is pressed it will
% perform this action.
%
% If changes are made in the table interface they will not be updated in
% If changes are made in the table interface they will not be updated in the
% underlying generated code in
% the simulink block until saving is performed, it is important to remember
% to save before closing the interface.
%
+57 −0
Original line number Diff line number Diff line
function [] = unsuppressed_file(file)

% look through a file for lines which are unsuppressed

string = [char(10) 'file = ' file char(10)];
fid = fopen(file);
data = fread(fid);
cstring = char(rot90(data));
lines = regexp(cstring,'\n','split');
count = 0;
for i = 1:size(lines,2)
    
    % dont look at comments at begining
    comment = regexp(char(lines(i)),'\s*%.*','once');
    
    if ~isempty(comment)
        continue;
    end
    
    keyword = regexp(strtrim(char(lines(i))),'^(end|function|methods|properties|classdef|for|if|else|switch|case|try|catch|otherwise|while|return|continue|warning|break)','once');
    if ~isempty(keyword)
        continue;
    end
    
    multiline = regexp(strtrim(char(lines(i))),'\.\.\.$','once');
    if ~isempty(multiline)
        continue;        
    end
    
    %get rid of empty strings
    if isempty(char(lines(i)))
        continue;
    end
    
    %get rid of empty lines with spaces
    if isempty(strtrim(char(lines(i))))
        continue;
    end
    
    semis = regexp(strtrim(char(lines(i))),'.*;(\s*%.*)*','once');
    if ~isempty(semis)
        continue;
    end
   
    
    count = count + 1;
    string = [string 'line <a href="matlab: opentoline(which(''' file '''),' num2str(i) ')">' num2str(i) '</a>: ' char(lines(i)) char(10)];
  
    
end

if count ~= 0
    fprintf('%s',string);

end

fclose(fid);
 No newline at end of file
+43 −0
Original line number Diff line number Diff line
function [] = unsuppressed_recursive(varargin)
%UNTITLED3 Summary of this function goes here
%   Detailed explanation goes here

% look in the current directory
switch nargin
    case 0
        current_directory = '.';
        recurse = true;
    case 1
        current_directory = varargin{1};
        recurse = true;
    case 2
        current_directory = varargin{1};
        recurse = varargin{2};
end


list_of_files = dir(current_directory);
for i = 1:size(list_of_files)
    % ignore the . and .. basically anything starting with . ie .svn, etc.
    no_search_dir = regexp(char(list_of_files(i).name),'^\.','once');
    if ~isempty(no_search_dir)
        continue;
    end
    if (list_of_files(i).isdir)
        if recurse
            
            unsuppressed_recursive([current_directory '/' list_of_files(i).name],recurse);
        end
    end
    
end

 what_info = what(current_directory);
        for j = 1:size(what_info.m,1)
            unsuppressed_file([current_directory '/' char(what_info.m(j))]);
        end



end