Idioms

Iterating over all segments

forall for (x) print secname(), x
forall for (x) if (x > 0 && x < 1) print secname(), x //leave out 0 area nodes

Data Structures

begintemplate Temp
	public str, obj, x
	strdef str
	objref obj
	x = 0
endtemplate Temp

objref temp
temp = new Temp()
temp.x = 2
temp.str = "hello"
temp.obj = new SectionList()

print temp, temp.x, temp.str, temp.obj

Adding a Graph so it works with the Standard Run Library

begintemplate P
        public flush, plot, begin, view_count
        objref this
        proc flush() { print this, "flush", t }
        proc plot() { print this, "plot", t }  
        proc begin() { print this, "begin", t }   
	func view_count() { print this, "view_count"   return 1}
endtemplate P

flush_list.append(new P()) // call flush every step
graphList[0].append(new P()) // call plot and flush every step

Arrays of strings

begintemplate String
	public s
	strdef s
	proc init() {
		if (numarg() == 1) {
			s = $s1
		}
	}
endtemplate String

objref sobj[5]
for i=0, 4 sobj[i] = new String()
for i=0, 4 sprint(sobj[i].s, "Number %d", i)
for i=0, 4 print sobj[i].s


NEURON's interpreter window

These aren't hoc idioms, but they can be helpful.

EMACS

These EMACS commands work for command line editing from the console (MSWin: NEURON's interpreter window).
^P     previous line (up arrow may also work; this crude history function can be applied repeatedly to scroll through prior commands)
^A     front of line
^E     end of line
^B     backward character
^F     forward character
Long command lines can be constructed by revision + accretion (recall a prior line, make changes and add new stuff to it).


NEURON summer course
Copyright © 1998, 1999 by N.T. Carnevale and M.L. Hines, all rights reserved.