view m-toolbox/classes/@LTPDAworkbench/cb_importFromMfile.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
line source

% CB_IMPORTFROMMFILE import an m-file to a pipeline.
%
% CALL: LTPDAworkbench.cb_importFromMfile
%
% M Hewitson 13-11-08
%
% $Id: cb_importFromMfile.m,v 1.4 2010/09/17 14:09:47 ingo Exp $
%
function cb_importFromMfile(varargin)
  
  wb = varargin{1};
  
  % Get file from user
  [filename, pathname] = uigetfile('*.m', 'Pick an M-file');
  if isequal(filename,0) || isequal(pathname,0)
    disp('User pressed cancel')
  else
    cmds = {};
    
    % get file parts
    fname = fullfile(pathname, filename);
    [pathstr,name,ext] = fileparts(fname);
    min = textread(fname,'%s','delimiter','\n','whitespace','');
    
    for kk=1:numel(min)
      line = strtrim(min{kk});
      % Exceptions:
      %   empty lines
      %   comment lines
      %   mc
      if ~isempty(line) && ...
          line(1) ~= '%' && ...
          ~strcmp(line, 'mc')
        
        cmds = [cmds min(kk)];
      end
    end
    
    % Now build the pipline
    wb.cmds2pipeline(name, cmds);
    
  end
  
end