Readme.txt for a function supplied by Bill Lytton (see below)
that locates a file within an environment variable called
HOC_LIBRARY_PATH that needs to be set, for example:
declare -x HOC_LIBRARY_PATH=/usr/site/nrniv/NRNB/share/nrn/lib/hoc/
before you start NEURON and use this routine. This function is
handy if you have a machine with a lot of copies of NEURON on it
and just want to focus on one.
The below shows the usage and the far below shows the function itself
that can be tucked into a file of your choosing...
objref aa,sfunc
oc> sfunc = new StringFunctions()
oc> {aa=hocfind("stdlib.hoc") print aa.s}
/usr/site/nrniv/NRNB/share/nrn/lib/hoc/stdlib.hoc
//* hocfind(FILENAME) searches through HOC_LIBRARY_PATH and locates file
obfunc hocfind () { local done localobj f1,s1,s2
f1=new File() s1=new String() s2=new String()
done=0
system("echo -n $HOC_LIBRARY_PATH",s1.s)
sprint(s1.s,"%s ",s1.s) // to look at last item
while (sfunc.len(s1.s)>2) {
sfunc.head(s1.s,"[ :]",s2.s)
sprint(s2.s,"%s/%s",s2.s,$s1)
if (f1.ropen(s2.s)) {done=1 break}
sfunc.tail(s1.s,"[ :]",s1.s)
}
if (!done) if (f1.ropen($s1)) {sprint(s2.s,"./%s",$s1) done=1}
if (!done) s2.s="NOT FOUND"
return s2
}
|