help understanding functions
Posted: Thu Aug 30, 2012 10:13 am
After quite a bit of playing around I think I have a function in which you pass in a list of sections (SectionList) and it creates a set of vectors for recording the membrane potential at each segment for each section in the list. I've spent a lot of time trying to understand procedures and functions and I was hoping to make sure I understood some of the main points.
NOTE: These are my thoughts and not necessarily right ...
1) Objects that are passed into a function must have been defined as objects previously. What about declaration of the type of object?
2) local and localobj prevent variables from showing up in the parent's workspace as well as from using the parent's variable with the same name in the function. Localobj means the objref declaration is not necessary.
Corrections or additions to the points above, as well as code improvement suggestions to the code below are most welcome.
Thanks,
Jim
NOTE: These are my thoughts and not necessarily right ...
1) Objects that are passed into a function must have been defined as objects previously. What about declaration of the type of object?
2) local and localobj prevent variables from showing up in the parent's workspace as well as from using the parent's variable with the same name in the function. Localobj means the objref declaration is not necessary.
Corrections or additions to the points above, as well as code improvement suggestions to the code below are most welcome.
Thanks,
Jim
Code: Select all
obfunc sim_logging__record_node_voltages(){ local cur_seg localobj node_vm_hist, tempRecVec, node_section_list
//sim_logging__record_node_voltages
//
// node_vm_hist = sim_logging__record_node_voltages(node_section_list)
//
//INPUTS
//---------------------------------------
//node_section_list - (Class SectionList)
//
//OUTPUTS
//node_vm_hist - (Class List) - holds vectors of membrane potentials at each segment
tempRecVec = new Vector()
node_vm_hist = new List()
node_section_list = $o1
cur_seg = 0
forsec node_section_list {
for (x,0) {
tempRecVec = new Vector()
tempRecVec.record(&v(x))
node_vm_hist.append(tempRecVec)
}
cur_seg = cur_seg + 1
}
return node_vm_hist
}