Mercurial > hg > octave-lyh
changeset 12590:b4bd0bef55b6 stable
getappdata.m: If appdata propery does not exist, return an empty matrix.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Mon, 11 Apr 2011 21:50:49 -0400 |
parents | c3d4542a4f06 |
children | 4727fd4dd4bb |
files | scripts/ChangeLog scripts/miscellaneous/getappdata.m |
diffstat | 2 files changed, 17 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2011-04-11 Ben Abbott <bpabbott@mac.com> + + * miscellaneous/getappdata.m: If appdata propery does not exist, return + an empty matrix. + 2011-04-08 Rik <octave@nomad.inbox5.com> * linear-algebra/cond.m, linear-algebra/expm.m, linear-algebra/logm.m,
--- a/scripts/miscellaneous/getappdata.m +++ b/scripts/miscellaneous/getappdata.m @@ -29,14 +29,20 @@ error ("getappdata: invalid input"); endif - appdata(numel(h)) = struct(); + ## FIXME - Is there a better way to handle non-existent appdata + ## and missing fields? + val = cell (numel (h), 1); + appdata = struct(); for nh = 1:numel(h) - appdata(nh) = get (h(nh), "__appdata__"); + try + appdata = get (h(nh), "__appdata__"); + catch + appdata.(name) = []; + end_try_catch + val(nh) = {appdata.(name)}; end - if (nh > 1) - val = {appdata.(name)}; - else - val = appdata.(name); + if (nh == 1) + val = val{1}; endif endfunction