Home > classes > @ao > attachm.m

attachm

PURPOSE ^

ATTACHM attach an m file to the analysis object.

SYNOPSIS ^

function varargout = attachm(varargin)

DESCRIPTION ^

 ATTACHM attach an m file to the analysis object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: ATTACHM attach an m file to the analysis object.

 CALL:        a = attachm(a, 'foo.m');
              a = attachm(a, plist);

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

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

 VERSION:     $Id: attachm.m,v 1.14 2008/09/05 11:05:28 ingo Exp $

 HISTORY:     31-03-07 M Hewitson
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % ATTACHM attach an m file to the analysis object.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: ATTACHM attach an m file to the analysis object.
0005 %
0006 % CALL:        a = attachm(a, 'foo.m');
0007 %              a = attachm(a, plist);
0008 %
0009 % M-FILE INFO: Get information about this methods by calling
0010 %              >> ao.getInfo('attachm')
0011 %
0012 %              Get information about a specified set-plist by calling:
0013 %              >> ao.getInfo('attachm', 'None')
0014 %
0015 % VERSION:     $Id: attachm.m,v 1.14 2008/09/05 11:05:28 ingo Exp $
0016 %
0017 % HISTORY:     31-03-07 M Hewitson
0018 %                 Creation
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 function varargout = attachm(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 and plists
0038   [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
0039   [pl, pl_invars,rest] = utils.helper.collect_objects(varargin(:), 'plist', in_names);
0040 
0041   % Decide on a deep copy or a modify
0042   bs = copy(as, nargout);
0043   
0044   % Combine with default plist
0045   pl = combine(pl, getDefaultPlist);
0046 
0047   % Get filename
0048   mfile = find(pl, 'filename');
0049   if isempty(mfile)
0050     % get filename from 'rest'
0051     for jj=1:numel(rest)
0052       if ischar(rest{jj})
0053         mfile = rest{jj};
0054         break;
0055       end
0056     end
0057   end
0058   if isempty(mfile)
0059     error('### No filename found in inputs.');
0060   end
0061 
0062   % Loop over AOs
0063   for jj=1:numel(bs)
0064 
0065     % get file parts
0066     [pathstr,name,ext,vers] = fileparts(mfile);
0067     if isempty(ext)
0068       mfile = [mfile '.m'];
0069     end
0070     min = textread(mfile,'%s','delimiter','\n','whitespace','');
0071     mout = '';
0072     for j=1:length(min)
0073       mout = [mout '\n' min{j}];
0074     end
0075 
0076     % attach to AO
0077     bs(jj).mfile = mout;
0078     bs(jj).mfilename = strrep(mfile, '''', '`');
0079   end
0080 
0081   % Set outputs
0082   if nargout > 0
0083     varargout{1} = bs;
0084   end
0085 end
0086 
0087 %--------------------------------------------------------------------------
0088 % Get Info Object
0089 %--------------------------------------------------------------------------
0090 function ii = getInfo(varargin)
0091   if nargin == 1 && strcmpi(varargin{1}, 'None')
0092     sets = {};
0093     pl   = [];
0094   else
0095     sets = {'Default'};
0096     pl   = getDefaultPlist;
0097   end
0098   % Build info object
0099   ii = minfo(mfilename, 'ao', '', utils.const.categories.helper, '$Id: attachm.m,v 1.14 2008/09/05 11:05:28 ingo Exp $', sets, pl);
0100 end
0101 %--------------------------------------------------------------------------
0102 % Get Default Plist
0103 %--------------------------------------------------------------------------
0104 function pl_default = getDefaultPlist()
0105   pl_default = plist();
0106 end
0107 
0108 % END
0109 
0110

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