# HG changeset patch # User jwe # Date 797214879 0 # Node ID 0ffb52e268d78c32b96e0d772081ec0eb5c129c6 # Parent c56c0565afd57630fa61d5d72e4ea807c2615f33 [project @ 1995-04-07 00:34:39 by jwe] diff -r c56c0565afd5 -r 0ffb52e268d7 src/data.cc --- a/src/data.cc Thu Apr 06 05:13:57 1995 +0000 +++ b/src/data.cc Fri Apr 07 00:34:39 1995 +0000 @@ -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) {