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);

 VERSION:     $Id: attachm.m,v 1.8 2008/03/06 13:47:48 mauro Exp $

 HISTORY:     31-03-07 M Hewitson
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = attachm(varargin)
0002 % ATTACHM attach an m file to the analysis object.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: ATTACHM attach an m file to the analysis object.
0007 %
0008 % CALL:        a = attachm(a, 'foo.m');
0009 %              a = attachm(a, plist);
0010 %
0011 % VERSION:     $Id: attachm.m,v 1.8 2008/03/06 13:47:48 mauro Exp $
0012 %
0013 % HISTORY:     31-03-07 M Hewitson
0014 %                 Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 
0018 VERSION  = '$Id: attachm.m,v 1.8 2008/03/06 13:47:48 mauro Exp $';
0019 CATEGORY = 'Helper';
0020 
0021 
0022 %% Check if this is a call for parameters
0023 if nargin == 2
0024   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0025     in = char(varargin{2});
0026     if strcmp(in, 'Params')
0027       varargout{1} = plist('filename', 'foo.m');
0028       return
0029     elseif strcmp(in, 'Version')
0030       varargout{1} = VERSION;
0031       return
0032     elseif strcmp(in, 'Category')
0033       varargout{1} = CATEGORY;
0034       return
0035     end
0036   end
0037 end
0038 
0039 
0040 %% Get inputs
0041 a        = varargin{1};
0042 % get filename from plist
0043 if isa(varargin{2}, 'plist')
0044   mfile = find(varargin{2}, 'filename');
0045 else % or directly
0046   mfile = varargin{2};
0047 end  
0048 if isempty(mfile)
0049   error('### You must specify a filename. Either directly, or in a plist');
0050 end
0051 
0052 if length(a) > 1
0053   error('### I can only deal with one AO at a time.');
0054 end
0055 
0056 
0057 %%
0058 [pathstr,name,ext,vers] = fileparts(mfile);
0059 if isempty(ext)
0060   mfile = [mfile '.m'];
0061 end
0062 min = textread(mfile,'%s','delimiter','\n','whitespace','');
0063 mout = '';
0064 for j=1:length(min)
0065   mout = [mout '\n' min{j}];
0066 end
0067 a.mfile     = mout;
0068 a.mfilename = strrep(mfile, '''', '`');
0069 
0070 varargout{1} = a;
0071 
0072 
0073 
0074

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003