Code: Select all
create soma, dend
begintemplate SectionInfo
external soma, dend
public name, access_nseg
objref sref
strdef name
proc init() {
name = $s1
print "In init, section name is: ",name
}
proc access_nseg() {local n
print "In access_nseg, section name is: ",name
print "In access_nseg, currently accessed section is ",secname(),", with nseg = ",nseg
print " which is why we need to change the currently accessed section."
print " Trying to use forsec to print the right name and nseg for section ", name, "..."
forsec name print "In access, using forsec, section ", secname(), " has nseg = ",nseg
print " .... didn't work. Change access manually to show that external worked..."
dend print "In access_nseg, with access changed manually, section ", secname(), " has nseg = ",nseg
}
endtemplate SectionInfo
access soma
nseg=3
dend.nseg=11
objref SD
dend SD = new SectionInfo(secname())
SD.access_nseg()
// Sanity check the offending line from the template "access" function
strdef name
name = "dend"
proc try_offending_line_in_base() {
forsec name print "Using forsec, section ", secname(), " has nseg = ",nseg
}
//try_offending_line_in_base()