help-octave
[Top][All Lists]
Advanced

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

class object methods and 'eval' function


From: pantxo diribarne
Subject: class object methods and 'eval' function
Date: Thu, 15 Sep 2011 13:42:27 +0200

Hello list,

I am currently writing a class using octave @folder framework.
I need to use eval to access  the fields of my object in the methods @myclass/get.m and @myclass/set.m but octave returns the same error as if I was trying to access the object fields from outside a method.

In get.m :
function varargout = get(p, arg)
  out = p.boardindex
  eval (["out = p." arg ";"]);
  varargout{ii} = out;
endfunction

Calling get with  " get (obj, 'boardindex')", where obj is a 'myclass' object, I obtain :

out =  2
error: invalid index for class
...

Is there a way to have eval function know that it is evaluated inside a method, or should I find the way not to use eval at all?

Pantxo




reply via email to

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