In 5.7 I am not able to define objects like Matrix & Vector within procedures, at least not directly (I never tried in earlier versions).
Am I doing something wrong? Or, is that just considered poor coding form?
I noticed that I am able to define them indirectly by using execute(str), where str = "m = new Matrix(2,10)" for example.
Defining objects within a procedure
-
- Site Admin
- Posts: 6299
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
A variable must be declared to be an objref before it can be
used as an objref. Objrefs must be declared at the top level
of the interpreter. Statements that appear within a proc or
func are not at the top level of the interpreter.
So this works
but this will generate an error msg
I believe that this is the way NEURON has worked
since objects were first added to the hoc interpreter.
used as an objref. Objrefs must be declared at the top level
of the interpreter. Statements that appear within a proc or
func are not at the top level of the interpreter.
So this works
Code: Select all
objref fap
proc foo() {
fap = new Classname()
}
Code: Select all
proc foo() {
objref fap
fap = new Classname()
}
since objects were first added to the hoc interpreter.