Working with sections in procedures
Posted: Wed Aug 29, 2012 12:25 pm
I was hoping to create a procedure which took an array of sections and connects them end to end. I was hoping to declare this procedure on startup. The latter statement is important because from what I gather procedures and functions have access to their parent's workspace, meaning if I previously define a section object before a procedure, I can work with that variable in the procedure without passing it in explicitly.
After a bit of searching I came across the class SectionRef, which I was hoping would accomplish what I want. However it appears as though SectionRef only applies to a single section, not an array of sections. Using the class functionality I can access children and parents of the section, but these don't exist until I connect them, which is what I am trying to do with the procedure.
Is there any way of creating a self contained procedure which accomplishes what I would like? Alternatively, if I am stuck with relying on the procedure being open to the parent, do I create a dummy section before defining the procedure, and then rely upon redefining that section before actually calling the procedure?
i.e. something like
NOTE: I would probably pass in n_sections. Ideally I could query this from the axon_sections ...
Thanks,
Jim
After a bit of searching I came across the class SectionRef, which I was hoping would accomplish what I want. However it appears as though SectionRef only applies to a single section, not an array of sections. Using the class functionality I can access children and parents of the section, but these don't exist until I connect them, which is what I am trying to do with the procedure.
Is there any way of creating a self contained procedure which accomplishes what I would like? Alternatively, if I am stuck with relying on the procedure being open to the parent, do I create a dummy section before defining the procedure, and then rely upon redefining that section before actually calling the procedure?
i.e. something like
NOTE: I would probably pass in n_sections. Ideally I could query this from the axon_sections ...
Code: Select all
create axon_sections
proc connect_axon(){
for i = 0, n_sections - 2{
connect axon_sections[i+1](0), axon_sections[i](1)
}
}
//DO THINGS HERE
create axon_sections[n_sections]
//DEFINE SECTIONS HERE
proc connect_axon()
Jim