view examples/globaldemo.cc @ 15998:59715612ea72

add a test for bug #38236 test/bug-38236/test_bug_38236.m,test/bug-38236/df_vr.m, test/bug-38236/u_vr.m: new files to test for bug #38236. test/Makefile.am: add test_bug_38236 to tests to run.
author Carlo de Falco <cdf@users.sourceforge.net>
date Tue, 05 Feb 2013 09:39:33 +0100
parents 4295d634797d
children be41c30bcb44
line wrap: on
line source

#include <octave/oct.h>

DEFUN_DLD (globaldemo, args, , "Global demo.")
{
  int nargin = args.length ();
  octave_value retval;

  if (nargin != 1)
    print_usage ();
  else
    {
      std::string s = args(0).string_value ();
      if (! error_state)
        {
          octave_value tmp = get_global_value (s, true);
          if (tmp.is_defined ())
            retval = tmp;
          else
            retval = "Global variable not found";

          set_global_value ("a", 42.0);
        }
    }
  return retval;
}