Variable names as variables

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc or Python
Post Reply
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Variable names as variables

Post 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
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post 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
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Post by mctavish »

Great answer, Ted. Thanks!
Post Reply