tstop is undefined

The basics of how to develop, test, and use models.
Post Reply
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

tstop is undefined

Post by Bill Connelly »

So the 4th line of code in my model is:
tstop = 100
And I would have thought, even if I didn't explicitely state what tstop was, it would have the defulat value of 5. Yet when I tried

Code: Select all

begintemplate SE_NetStim
public pp
objref pp
proc init() {
  pp = new NetStim()
  pp.interval = $1
  pp.number = $1*tstop*2
  pp.start = $2
  pp.noise = 1
}
...
endtemplate SE_NetStim
I got the error:
nrniv: undefined variable tstop
Are templates considered before everything else? Is there a way to get around this?
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: tstop is undefined

Post by ted »

By default, names defined at the top level (i.e. defined outside of a template) cannot be accessed by code inside an object (i.e. statements inside the template that defines the object's class). The "external" keyword is used to allow the object to access top level variables. Similarly, names declared inside a template are by default inaccessible from the top level unless they are declared as "public." To learn more about external and public see http://www.neuron.yale.edu/neuron/stati ... rogramming
Post Reply