Page 1 of 1

Problem with 'chooser' mode "d" in nrn 5.8

Posted: Tue Dec 06, 2005 2:48 pm
by mmoffitt
In Neuron 5.8 I have not been able to use

file.chooser("d")

to select a directory. I need to be able to select a directory with an xpanel. Does anyone know of a work-around? Or, is there a new chooser mode that I should use instead?

Thanks.

Documentation terse or wrong? How to get the right answer.

Posted: Wed Dec 07, 2005 10:39 am
by ted
This is just one of many cases in which the documentation is not explicit enough,
or is just plain incorrect. When this happens, it is often possible to discover an example
of correct usage.

Where? In NEURON's GUI library. NEURON's GUI is almost entirely implemented in
hoc, and you'll find all of this code in c:\nrnxx\lib\hoc (MSWin) or nrn/share/nrn/lib/hoc
(UNIX/Linux/OS X).

For this particular problem, I cd'd to that location, then executed
grep chooser *hoc | less
An aside for MSWin users: Start an xterm by clicking on the rxvt.sh icon,
which begins with c/nrn58 as the working directory. cd to lib/hoc and then run
grep chooser *hoc
(sorry, less isn't included at present). Finally, use the scroll bar at the left edge of the
xterm to review the items that grep found.

This revealed that mknrndll.hoc contained some likely stuff:

Code: Select all

mknrndll.hoc:   ldfile.chooser("d", "Directory", "", "Make nrnmech.dll", "Cancel", getcwd())
mknrndll.hoc:   if (ldfile.chooser()) {
It also showed me that there wasn't a single instance of the single argument usage
ldfile.chooser("d")
in the entire GUI library. Is this a bug in the chooser() method, or a bug in the
documentation? Who cares--at least we know how to use chooser().

Examining the contents of mknrndll.hoc, I found a procedure that gave a very clear
example of usage:

Code: Select all

proc change_working_dir() {
        ldfile.chooser("d", "Directory", "", "Make nrnmech.dll", "Cancel", getcwd())
        if (ldfile.chooser()) {
                read_recent_working_dirs()
                if (change_working_dir1(ldfile.dir)) {
                        exec()
                }
        }
}
So steal this code and make whatever changes you need to do what you want.

bugs were to blame

Posted: Thu Dec 08, 2005 10:39 am
by ted
I brought this to Michael Hines's attention. His reply:
There turned out to be two bugs in the code which made it so that unless there was an
"accept" argument, the "d" got turned into a "w".
That fix is available via cvs and will appear in the next alpha version.