Mercurial > octave-nkf
annotate scripts/miscellaneous/isappdata.m @ 14138:72c96de7a403 stable
maint: update copyright notices for 2012
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 02 Jan 2012 14:25:41 -0500 |
parents | b0084095098e |
children | f3d52523cde1 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11589
diff
changeset
|
1 ## Copyright (C) 2010-2012 Ben Abbott |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2 ## |
11180 | 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. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
7 ## |
11180 | 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. | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
12 ## |
11180 | 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} {@var{V} =} isappdata (@var{h}, @var{name}) | |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11180
diff
changeset
|
19 ## Return true if the named application data, @var{name}, exists for the |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
20 ## object with handle @var{h}. |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11180
diff
changeset
|
21 ## @seealso{getappdata, setappdata, rmappdata} |
11180 | 22 ## @end deftypefn |
23 | |
24 ## Author: Ben Abbott <bpabbott@mac.com> | |
25 ## Created: 2010-07-15 | |
26 | |
27 function res = isappdata (h, name) | |
28 | |
29 if (! (all (ishandle (h)) && ischar (name))) | |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11588
diff
changeset
|
30 error ("isappdata: invalid input"); |
11180 | 31 endif |
32 | |
33 for nh = 1:numel(h) | |
34 data = get (h(nh)); | |
35 if (isfield (data, "__appdata__") && isfield (data.__appdata__, name)) | |
36 res(nh) = true; | |
37 else | |
38 res(nh) = false; | |
39 endif | |
40 endfor | |
41 | |
42 endfunction | |
43 | |
44 %!test | |
45 %! setappdata (0, "hello", "world") | |
46 %! assert (isappdata (0, "hello"), true) | |
47 %!assert (isappdata (0, "foobar"), false) | |
48 |