oren wrote:Is it possible to know if a section is in sectionlist?
One problem with your code is that it corrupts the section list that you are trying to test. sl.append() ensures that n1 will be >=1, so
is guaranteed to fail to remove the appended section. Another problem is that it won't be very useful unless it's written as a function. Here's something that addresses both of these problems
Code: Select all
func insl() { localobj tobj
// first copy $o1's contents into a new SectionList()
tobj = new SectionList()
forsec $o1 tobj.append()
// now append the section of interest
tobj.append()
return (tobj.unique>0)
}
and an example of usage
Code: Select all
create soma, dend, axon
objref sl1, sl2
sl1 = new SectionList()
sl2 = new SectionList()
forall sl1.append()
forall sl2.append()
axon sl2.remove()
result = -1
axon result = insl(sl1)
print "is axon in sl1? ", result
axon result = insl(sl2)
print "is axon in sl2? ", result
soma2{issection("soma{1-10}\|soma{20-25}")}
should return 1 but I receive 0
It doesn't surprise me that
soma2{issection("soma{1-10}")}
returns nothing, because embedding statements in curly brackets suppresses printout of values returned by funcs, e.g.
oc>sqrt(2)
returns
1.414...
but
oc>{ sqrt(2) }
returns nothing. That said,
oc>{ print sqrt(2) }
prints
1.414...
to the terminal, and
oc>soma2{ print issection("soma{1-10}") }
prints 1.
But when I try
soma2{ print issection("soma{1-10}\|soma{20-25}") }
sure enough, the result is 0!
The workaround is to split this into two calls to issection, and OR the results.
soma2{print issection("soma{1-10}") || issection("soma{20-25}")}
prints 1.