]> Creatis software - CreaPhase.git/blob - octave_packages/m/miscellaneous/rmappdata.m
update packages
[CreaPhase.git] / octave_packages / m / miscellaneous / rmappdata.m
1 ## Copyright (C) 2010-2012 Ben Abbott
2 ##
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.
7 ##
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.
12 ##
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/>.
16
17 ## -*- texinfo -*-
18 ## @deftypefn {Function File} {} rmappdata (@var{h}, @var{name})
19 ## Delete the named application data for the object(s) with
20 ## handle(s) @var{h}.
21 ## @end deftypefn
22
23 ## Author: Ben Abbott <bpabbott@mac.com>
24 ## Created: 2010-07-15
25
26 function rmappdata (h, varargin)
27
28   if (! (all (ishandle (h)) && iscellstr (varargin)))
29     error ("rmappdata: invalid input");
30   endif
31
32   for nh = 1:numel(h)
33     appdata = get (h(nh), "__appdata__");
34     appdata = rmfield (appdata, varargin);
35     set (h(nh), "__appdata__", appdata);
36   endfor
37
38 endfunction
39
40 %!test
41 %! setappdata (0, "hello", "world")
42 %! rmappdata (0, "hello")
43 %! assert (isappdata (0, "hello"), false)
44