1 ## Copyright (C) 2010-2012 Ben Abbott
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with Octave; see the file COPYING. If not, see
15 ## <http://www.gnu.org/licenses/>.
18 ## @deftypefn {Function File} {@var{value} =} getappdata (@var{h}, @var{name})
19 ## Return the @var{value} for named application data for the object(s) with
21 ## @deftypefnx {Function File} {@var{appdata} =} getappdata (@var{h})
22 ## Return a structure, @var{appdata}, whose fields correspond to the appdata
26 ## Author: Ben Abbott <bpabbott@mac.com>
27 ## Created: 2010-07-15
29 function val = getappdata (h, name)
31 if (all (ishandle (h)) && nargin == 2 && ischar (name))
32 ## FIXME - Is there a better way to handle non-existent appdata
33 ## and missing fields?
34 val = cell (numel (h), 1);
38 appdata = get (h(nh), "__appdata__");
40 if (! isfield (appdata, name))
43 val(nh) = {appdata.(name)};
48 elseif (ishandle (h) && numel (h) == 1 && nargin == 1)
50 val = get (h, "__appdata__");
55 error ("getappdata: invalid input");