Mercurial > octave
diff src/symtab.cc @ 7437:3e450caf93f2
[project @ 2008-02-01 08:19:05 by jwe]
author | jwe |
---|---|
date | Fri, 01 Feb 2008 08:19:05 +0000 |
parents | 745a8299c2b5 |
children | 0ff0fc033f28 |
line wrap: on
line diff
--- a/src/symtab.cc Fri Feb 01 06:58:29 2008 +0000 +++ b/src/symtab.cc Fri Feb 01 08:19:05 2008 +0000 @@ -798,6 +798,55 @@ return retval; } +#if 0 + +// FIXME -- should we have functions like this in Octave? + +DEFUN (set_variable, args, , "set_variable (NAME, VALUE)") +{ + octave_value retval; + + if (args.length () == 2) + { + std::string name = args(0).string_value (); + + if (! error_state) + symbol_table::varref (name) = args(1); + else + error ("set_variable: expecting variable name as first argument"); + } + else + print_usage (); + + return retval; +} + +DEFUN (variable_value, args, , "VALUE = variable_value (NAME)") +{ + octave_value retval; + + if (args.length () == 1) + { + std::string name = args(0).string_value (); + + if (! error_state) + { + retval = symbol_table::varval (name); + + if (retval.is_undefined ()) + error ("variable_value: `%s' is not a variable in the current scope", + name.c_str ()); + } + else + error ("variable_value: expecting variable name as first argument"); + } + else + print_usage (); + + return retval; +} +#endif + /* ;;; Local Variables: *** ;;; mode: C++ ***