Home > marsbar > @marmoire > add_item.m

add_item

PURPOSE ^

add item to armoire

SYNOPSIS ^

function o = add_item(o, item_name, item_contents)

DESCRIPTION ^

 add item to armoire
 FORMAT o = add_item(o, item, I)
 
 o              - object
 item_name     - item name
 item_contents = item ... contents

 $Id $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function o = add_item(o, item_name, item_contents)
0002 % add item to armoire
0003 % FORMAT o = add_item(o, item, I)
0004 %
0005 % o              - object
0006 % item_name     - item name
0007 % item_contents = item ... contents
0008 %
0009 % $Id $
0010   
0011 if nargin < 2
0012   error('Need item name to add');
0013 end
0014 if nargin < 3
0015   item_contents = [];
0016 end
0017 I = default_item(o);
0018 if isempty(item_contents)
0019   item_contents = I;
0020 else
0021   def_fns = fieldnames(I);
0022   new_fns = def_fns(~ismember(def_fns, fieldnames(item_contents)));
0023   for fn = new_fns'
0024     item_contents = setfield(item_contents, fn{1}, getfield(I, fn{1}));
0025   end
0026 end
0027 o = set_item_struct(o, item_name, item_contents);

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019