
begintemplate Cell
public soma, dend, axon, pr
create soma, dend[1], axon

proc init() {
	ndend = $1
	create dend[ndend]
	soma connect axon(0), 0
	for i=0,ndend-1 soma connect dend[i](0), 1
	geometry($2)
	membrane()
}

proc geometry() {
	soma { nseg=1 L=30 diam=30 }
	axon { nseg=10 L=1000 diam=5 }
	forsec "dend" {nseg=$1 L=200 diam(0:1) = 5:1 }
}

proc membrane() {
	soma {insert hh}
	axon {insert hh}
	forsec "dend" {insert pas  g_pas=.001  e_pas=-65}
}

strdef s
proc pr() {
	forall { sectionname(s) print s}
}

endtemplate Cell

objectvar cell[3]
cell[0] = new Cell(4, 5)
cell[1] = new Cell(2, 10)
cell[2] = new Cell(6, 2)

topology()

for i=0,2 cell[i].pr()

objectvar allsoma
allsoma = new SectionList()
forall ifsec "soma" allsoma.append()
strdef s
forsec allsoma {sectionname(s) print s}

allsoma.printnames()
