Mercurial > hg > octave-nkf
changeset 1216:0ffb52e268d7
[project @ 1995-04-07 00:34:39 by jwe]
author | jwe |
---|---|
date | Fri, 07 Apr 1995 00:34:39 +0000 |
parents | c56c0565afd5 |
children | 8ec4c0c375a2 |
files | src/data.cc |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/data.cc +++ b/src/data.cc @@ -35,6 +35,7 @@ #include "tree-const.h" #include "user-prefs.h" +#include "oct-map.h" #include "help.h" #include "utils.h" #include "error.h" @@ -740,6 +741,34 @@ return retval; } +DEFUN ("struct_contains", Fstruct_contains, Sstruct_contains, 1, 2, + "struct_contains (S, NAME)\n\ +\n\ +return nonzero if S is a structure with element NAME") +{ + Octave_object retval; + + int nargin = args.length (); + + if (nargin == 2) + { + retval = 0.0; + if (args(0).is_map ()) + { + if (args(1).is_string ()) + { + Octave_map m = args(0).map_value (); + char *s = args(1).string_value (); + retval = (double) (s && m.contains (s)); + } + } + } + else + print_usage ("struct_contains"); + + return retval; +} + static void check_dimensions (int& nr, int& nc, const char *warnfor) {