Home > classes > @ao > extractm.m

extractm

PURPOSE ^

EXTRACTM extracts an m-file from an analysis object and saves it to disk.

SYNOPSIS ^

function varargout = extractm(varargin)

DESCRIPTION ^

 EXTRACTM extracts an m-file from an analysis object and saves it to disk.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: EXTRACTM extracts an m-file from an analysis object and saves it to
              disk.

 CALL:        extractm(a)

 M-FILE INFO: Get information about this methods by calling
              >> ao.getInfo('extractm')

              Get information about a specified set-plist by calling:
              >> ao.getInfo('extractm', 'None')

 VERSION:     $Id: extractm.m,v 1.7 2008/09/05 11:05:29 ingo Exp $

 HISTORY:     23-02-08 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % EXTRACTM extracts an m-file from an analysis object and saves it to disk.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: EXTRACTM extracts an m-file from an analysis object and saves it to
0005 %              disk.
0006 %
0007 % CALL:        extractm(a)
0008 %
0009 % M-FILE INFO: Get information about this methods by calling
0010 %              >> ao.getInfo('extractm')
0011 %
0012 %              Get information about a specified set-plist by calling:
0013 %              >> ao.getInfo('extractm', 'None')
0014 %
0015 % VERSION:     $Id: extractm.m,v 1.7 2008/09/05 11:05:29 ingo Exp $
0016 %
0017 % HISTORY:     23-02-08 M Hewitson
0018 %                 Creation
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 function varargout = extractm(varargin)
0023 
0024   % Check if this is a call for parameters
0025   if utils.helper.isinfocall(varargin{:})
0026     varargout{1} = getInfo(varargin{3});
0027     return
0028   end
0029 
0030   import utils.const.*
0031   utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
0032   
0033   % Collect input variable names
0034   in_names = cell(size(varargin));
0035   for ii = 1:nargin,in_names{ii} = inputname(ii);end
0036 
0037   % Collect all AOs
0038   [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
0039 
0040   % Loop over AOs
0041   for jj=1:numel(as)
0042     if isempty(as(j).mfile)
0043       warning('!!! No mfile found in %s. Skipping.', ao_invars{j});
0044     end
0045     if isempty(as(j).mfilename)
0046       warning('!!! No filename found in %s. Skipping.', ao_invars{j});
0047     end
0048     % split mdl contents by \n in to cell array
0049     mfile     = regexp(as(j).mfile, '\\n', 'split');
0050     % reformat into a big string
0051     txt = sprintf([repmat('%s\t',1,size(mfile,1)),'\n'],mfile{:});
0052     txt = strrep(txt, '`', '''');
0053     % write string to disk
0054     fd = fopen(as(j).mfilename, 'w+');
0055     fwrite(fd, txt);
0056     fclose(fd);
0057 
0058     utils.helper.msg(msg.PROC1, 'saved m-file to %s', as(j).mfilename);
0059   end
0060 
0061   % Set output
0062   if nargout > 0
0063     varargout{1} = as;
0064   end
0065 end
0066 
0067 %--------------------------------------------------------------------------
0068 % Get Info Object
0069 %--------------------------------------------------------------------------
0070 function ii = getInfo(varargin)
0071   if nargin == 1 && strcmpi(varargin{1}, 'None')
0072     sets = {};
0073     pl   = [];
0074   else
0075     sets = {'Default'};
0076     pl   = getDefaultPlist;
0077   end
0078   % Build info object
0079   ii = minfo(mfilename, 'ao', '', utils.const.categories.output, '$Id: extractm.m,v 1.7 2008/09/05 11:05:29 ingo Exp $', sets, pl);
0080 end
0081 
0082 %--------------------------------------------------------------------------
0083 % Get Default Plist
0084 %--------------------------------------------------------------------------
0085 function pl_default = getDefaultPlist()
0086   pl_default = plist();
0087 end
0088

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003