Read chapter 12 of the NEURON Book and you'll see the cause of your problem. Actually, this should also be explained in the Programmer's Reference. For those who don't have the book, here's a brief summary.
hoc is a typed language. User-created names can be used to refer to scalars, arrays, strings, names for user-defined classes, class names, object instances, or sections. The first occurrence of a user-created name in a program "declares" which of these things it refers to. The only type declaration that is completely automatic is scalar. So
foo = 3.14
is OK (makes foo a scalar), and this "declaration by assignment" works regardless of whether foo first appears inside or outside of a proc or func. If you want foo to be an array of double precision numbers, you first have to declare at least
double foo[1]
outside of any proc or func so that hoc knows foo is an array. Then you can do
Code: Select all
proc bigfoo() {
double foo[3]
for i = 0,2 foo[i] = i*i
}
Similarly, hoc won't let you execute
create bar
inside a func or proc unless a
create bar
statement has already been executed outside of a func or proc. And it definitely won't let you create an "array of sections"
create axon[3]
inside a func or proc unless a statement like
create axon[1]
has already been executed outside of a func or proc.