Page 1 of 1

Function call

Posted: Sun Mar 07, 2010 7:39 pm
by tcp
Dear Forum,

How do I schedule a function call at a specified time instant (in either hoc or mod files)?

Thanks and regards,
Eleftheria

Re: Function call

Posted: Mon Mar 08, 2010 10:55 am
by ted
You could use the CVode class's event() method, or the NetCon class's record() method.

Since the event queue is cleared during initialization, the first call to CVode.event should be done after that happens. It is convenient to do this with an FInitializeHandler. Example:

Code: Select all

proc printpi() {
  print PI
}

objref foo
foo = new CVode()

objref fih
fih = new FInitializeHandler(0, "foo.event(2, \"printpi()\")")
Every time run() is called, NEURON will print 3.1415927 when t == 2. For an example that uses CVode.event and FInitializeHandler to implement a series of current pulses, see https://www.neuron.yale.edu/phpBB2/view ... t=162#p368

If you use the NetCon class's record() method, you need an event source. For that you could employ a NetStim as the event source, or an FInitializeHandler that calls NetCon.event.