Function call

Anything that doesn't fit elsewhere.
Post Reply
tcp

Function call

Post 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
ted
Site Admin
Posts: 6394
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Function call

Post 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.
Post Reply