help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

curr_sym_tab?


From: John W. Eaton
Subject: curr_sym_tab?
Date: Tue, 25 Apr 2000 01:55:57 -0500 (CDT)

On 20-Apr-2000, Stef Pillaert <address@hidden> wrote:

| in my .oct-functions, I had a way (in octave-2.0.?) to set local or global
| octave_values, so that I could use eval on those values. JWE was so kind to
| provide a simple way to do this.
| My problem is that this doesn't seem to work in octave-2.1.30 anymore.
| Anyone has experience on this? "curr_sym_tab" doesn't seem to exist
| anymore...

It is declared in variables.h.

2.1.x already includes get_global_value and set_global_value
functions.

I don't understand why you need functions that access the local symbol
table, or why your local_oct function is needed.  Can't you accomplish
the same thing using eval?

jwe


| An extract from the code:
| 
|   #include <octave/oct.h>
|   #include <octave/symtab.h>
|   #include "local_oct.h"
| 
|   octave_value
|   get_local_value (const string& nm)
|   {
|     octave_value retval;
| 
|     const symbol_record *const sr = curr_sym_tab->lookup (nm);
| 
|     if (sr)
|       {
|  const octave_value val = sr->variable_value ();
| 
|  if (val.is_undefined ())
|    error ("get_local_value: undefined symbol %s'", nm.c_str ());
|  else
|    retval = val;
|       }
|     else
|       error ("get_local_value: unknown symbol %s'", nm.c_str ());
| 
|     return retval;
|   }
| 
| ...
| 
|   DEFUN_DLD (local_oct, args, ,
|     "local_oct (local_variable_name [, val])
|   called with two values, it sets the value of the named local variable
|   to the value of the second argument.
|   If called with just one argument, it finds the value
|  of the named local variable")
|   {
|     octave_value_list retval;
| 
|     const int nargin = args.length ();
| 
|     if (nargin == 1 || nargin == 2)
|       {
|  const string var = args(0).string_value ();
| 
|  if (! error_state)
|    {
|      if (nargin == 2)
|        set_local_value (var, args(1));
|      else
|        retval(0) = get_local_value (var);
|    }
|       }
| 
|     return retval;
|   }



-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]