nw:with-context
nw:with-context turtleset linkset command-block
Executes the command-block with the context temporarily set to turtleset and linkset. After command-block finishes running, the previous context will be restored.
For example:
observer> create-turtles 3 [ create-links-with other turtles ]
observer> nw:with-context (turtle-set turtle 0 turtle 1) (link-set link 0 1) [ show nw:get-context ]
observer: [(agentset, 2 turtles) (agentset, 1 link)
observer> show nw:get-context
observer: [turtles links]
If you have NW extension code running in two forever buttons or loop
blocks that each need to use different contexts, you should use nw:with-context
in each to make sure they are operating in the correct context.
Take me to the full Networks Extension Dictionary