Page 1 of 1

Evaluate with localobj

Posted: Thu Feb 21, 2008 1:13 pm
by mctavish
I'm trying to execute the following:

Code: Select all

// $s1 is the name of a cell type
proc method() { localobj str, cell
   str=new String("cell=new ")
   sprint(str.s,"%s%s",str.s,$s1)
   sprint(str.s,"%s%s",str.s,"()")
   execute1(str.s)
      .
      .
      .
}
This will work of cell is not a localobj and is outside of the method, but I'd much rather it stay local. How do I make

Code: Select all

execute1("someLocalObj=new someObj()")
work?

Posted: Fri Feb 22, 2008 11:04 am
by hines
There is no good way. I recommend a
global objref or one in a class. But if you
really don't like adding a name to the namespace and don't mind some extra creation/destruction you can use

Code: Select all

obfunc objeval() { localobj l, s
        s = new String()
        l = new List()
        sprint(s.s, "%s.append(new %s())", l, $s1)
        execute(s.s)
        return l.object(0)
}

Posted: Fri Feb 22, 2008 3:52 pm
by mctavish
Thanks, Ted.

Posted: Fri Feb 22, 2008 3:52 pm
by mctavish
Whoops! I mean thanks Michael!