Page 1 of 1

Variable names as variables

Posted: Mon Aug 14, 2006 11:50 am
by mctavish
I am trying to implement a general cross-correlation GUI where the user types in the variable names to be cross-correlated. I have two problems.

1) How can I make a field where the user can type the name of the variable? Alternatively, how can I interface with the variable window that comes up in the "Plot What?" of a graph to obtain variables/ variable names?

2) Given a user-defined variable as just described, how can I then use it in cvode.record()? The problem is that I can hard-code a variable name in hoc code, but I do not see a way to have the first parameter dynamically assigned.

Thanks,
Tom

Posted: Mon Aug 14, 2006 2:43 pm
by ted
1) How can I make a field where the user can type the name of the variable? Alternatively, how can I interface with the variable window that comes up in the "Plot What?" of a graph to obtain variables/ variable names?
You want to use a SymChooser.
http://www.neuron.yale.edu/neuron/stati ... SymChooser
2) Given a user-defined variable as just described, how can I then use it in cvode.record()? The problem is that I can hard-code a variable name in hoc code, but I do not see a way to have the first parameter dynamically assigned.

So don't hard code it. Use sprint
http://www.neuron.yale.edu/neuron/stati ... tml#sprint
to assemble the command string you want, then use execute
http://www.neuron.yale.edu/neuron/stati ... ml#execute
to execute that string.

Here's a general strategy for how to find answers in the Programmer's Reference:
https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=554

Posted: Wed Aug 16, 2006 3:55 pm
by mctavish
Great answer, Ted. Thanks!