Page 1 of 1

tstop is undefined

Posted: Wed Aug 05, 2009 5:55 pm
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?

Re: tstop is undefined

Posted: Wed Aug 05, 2009 9:27 pm
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