OJAG wrote:a.)How to assign the name of a previously defined string to a NEURON variable/object?
It is not clear whether you are asking how to use a string as the name of a strdef, double, or objref, or whether the question is how to use a string as a _second_ name for an existing strdef, double, or objref.
If your question is the former: the idiom is
strdef cmd
sprint(cmd,
format string,
variable names)
execute(cmd)
For example,
strdef foo
foo = "whatever"
strdef cmd
sprint(cmd, "%s = %f", foo, sqrt(2))
execute(cmd)
creates a new double called whatever with the value 1.414214...
For objects, there must be two sprint/execute pairs. The first pair
sprint(cmd, "objref %s", foo)
execute(cmd)
is needed to make whatever be an objref. The second pair
sprint(cmd, "%s = new SomeClassName()", foo)
is needed to make whatever point to an instance of SomeClassName.
If your question is the latter, here is your answer: in hoc there is no way to make multiple names refer to the same double or strdef. However, multiple objref names may refer to a single object.
objref bar
bar = new Vector()
strdef foo
foo = "whatever"
strdef cmd
sprint(cmd, "objref %s", foo)
execute(cmd)
sprint(cmd, "%s = %s", foo, "bar")
execute(cmd) // the command is "whatever = bar"
print bar // demonstrate that foo and bar refer to the same Vector instance
print whatever