Opening a hoc-file twice with the gui

The basics of how to develop, test, and use models.
Post Reply
basjanzandt

Opening a hoc-file twice with the gui

Post by basjanzandt »

I have installed Neuron (on windows Vista, and installed Cygwin previously) and I am working my way through the tutorial and playing a bit around.
I try to run some lines of code by opening a .hoc file, say test.hoc. This works fine if I set the working directory and type xopen("test.hoc").

It also works fine if I use the menu: File->Load hoc and then double-click test.hoc.
However, if I now try to run the hoc-code for a second time by using File->Load hoc, nothing happens. I can load and run other hoc-files, but all files only once.

Does anybody have an idea what's causing this, and if it can be fixed?

Thanks
ted
Site Admin
Posts: 6305
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Opening a hoc-file twice with the gui

Post by ted »

"This is a feature, not a bug."

xopen() reads the specified file each time it is executed.

NEURON Main Menu / File / load session
and
NEURON Main Menu / File / load hoc
use load_file() to read the selected file. load_file() opens the file only if it has not already been loaded. See the documentation for load_file()
http://www.neuron.yale.edu/neuron/stati ... #load_file

The reason for load_file()'s "limitation" is to prevent conflicts that might arise from trying to load the same file more than once. Such conflicts will arise if files contain templates (definitions of new classes). If you try to read such a file more than once, hoc will complain that it can't redefine a class--you have to exit NEURON and restart. Conflicts are also likely to arise if you reopen a file that contains create or connect statements.

But a file that simply creates xpanels or instances of existing classes can generally be reopened without problems.

If you have a file that doesn't cause problems when xopened, you can save yourself some typing by using the keyboard's up arrow to recall previous commands typed at the oc> prompt.
basjanzandt

Re: Opening a hoc-file twice with the gui

Post by basjanzandt »

Thanks for the clear reply!

Unfortunately I cannot use the arrows in the GUI for some reason, but ctrl+P works instead.
Post Reply