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.