Evaluate with localobj

The basics of how to develop, test, and use models.
Post Reply
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Evaluate with localobj

Post 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?
hines
Site Admin
Posts: 1615
Joined: Wed May 18, 2005 3:32 pm

Post 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)
}
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Post by mctavish »

Thanks, Ted.
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Post by mctavish »

Whoops! I mean thanks Michael!
Post Reply