On Monday, July 25, 2016 at 9:08:34 AM UTC-6, Dave Dixon wrote:
>
> On Friday, March 2, 2012 at 8:47:52 AM UTC-7, Arthur Hjorth wrote: 
> > Hi all, 
> > 
> > 
> > I'm writing an extension that allows users to concurrently run models 
> from a model. It works by loading up a number of HeadlessWorkspaces and 
> loading a model in them.  
> > 
> > 
> > For the sake of making NetLogo code writing easier "between models" I 
> was hoping to write a reporter primitive in the extension that shows all 
> turtle/global vars and procedures in one of the loaded models. The idea 
> would be that it could be executed from the command line, i.e. 
> > 
> > 
> > [extension name]:showmeprocedures [model name] 
> > 
> > 
> > I am thinking it would either be 1) running Reflection in Java on the 
> model and returning a string or LogoList of methods and vars, or 2) simply 
> a method in the extension that parses the netlogo code from the relevant 
> .nlogo file, finds the relevant bits, and returns them to NetLogo. I am 
> thinking probably 2 is easier (though more error prone if the NetLogo code 
> is messy), but I am unsure of how to get just the NetLogo code out of a 
> .nlogo file. 
> > 
> > 
> > Thoughts or tips, anyone? 
> > 
> > 
> > - Arthur 
>
> That's all very cool! I'd like to get the current workspace object from 
> within an Extension object and do the Java equivalent of 
> ws.world.program.globals. Is it possible? 
>

UPDATE: What I've figured out by random walk through the Extension 
documentation is to include the following in the report method for a 
DefaultReporter  
      ExtensionContext ec = (ExtensionContext)context;
      Workspace ws = ec.workspace();       
      World world = ws.world();
      Program prog = world.program();

      for (String global : prog.globals()){ 
        /* obs.getClass() is Double, String, etc. */
        Object obs = world.getObserverVariableByName(global);
        . . .
      }

-- 
You received this message because you are subscribed to the Google Groups 
"netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to