Mercurial > hg > octave-nkf
comparison scripts/plot/isprop.m @ 13214:7715aca4bce1
Allow an nd-array of handles when calling isprop.m.
* scripts/plot/isprop.m: Support non-scalar hangles. Add test.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 25 Sep 2011 11:55:39 -0400 |
parents | c792872f8942 |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
13213:544304a09e42 | 13214:7715aca4bce1 |
---|---|
28 ## Check input | 28 ## Check input |
29 if (nargin < 1 || nargin > 2) | 29 if (nargin < 1 || nargin > 2) |
30 print_usage (); | 30 print_usage (); |
31 endif | 31 endif |
32 | 32 |
33 if (! ishandle (h)) | 33 if (! all (ishandle (h))) |
34 error ("isprop: first input argument must be a handle"); | 34 error ("isprop: first input argument must be a handle"); |
35 elseif (! ischar (prop)) | 35 elseif (! ischar (prop)) |
36 error ("isprop: second input argument must be string"); | 36 error ("isprop: second input argument must be string"); |
37 endif | 37 endif |
38 | 38 |
39 res = true; | 39 res = false (size (h)); |
40 try | 40 for n = 1:numel(res) |
41 v = get (h, prop); | 41 res(n) = true; |
42 catch | 42 try |
43 res = false; | 43 v = get (h(n), prop); |
44 end_try_catch | 44 catch |
45 res(n) = false; | |
46 end_try_catch | |
47 endfor | |
45 endfunction | 48 endfunction |
46 | 49 |
47 %!assert (isprop (0, "foobar"), false) | 50 %!assert (isprop (0, "foobar"), false) |
48 | 51 |
49 %!assert (isprop (0, "screenpixelsperinch"), true) | 52 %!assert (isprop (0, "screenpixelsperinch"), true) |
50 | 53 |
54 %!assert (isprop (zeros (2, 3), "visible"), true (2, 3)) | |
55 |