Finding parent section name and location
Finding parent section name and location
I want to be able to return the parent section name and location (e.g., "dend[4](0.3)") for any child section. I see the SectionRef documentation (https://www.neuron.yale.edu/neuron/stat ... ecref.html), but don't know how to implement it in hoc. Would like to see a few lines of sample code which would return the parent name and location for any identified child section. Thanks.
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Finding parent section name and location
This will report the name of the root section, the name of each child section, and the name of the parent and location on the parent to which the child is attached. I assume you will read about any unfamiliar keywords in the Programmer's Reference.
Code: Select all
// usage: reportparents()
strdef str
proc reportparents() { local x localobj tobj
forall {
str = secname()
tobj = new SectionRef()
if (tobj.has_parent()) {
// tobj.parent {print secname(), " is parent of ", str}
x = parent_connection()
tobj.parent {print str, " is attached to ", secname(), "(", x, ")"}
} else {
print str, " doesn't have a parent"
}
}
}