Can I pass a parameter to a hoc file when executing it from the shell? Something like
Code: Select all
sparc/special myFile.hoc num=3
Thanks
Code: Select all
sparc/special myFile.hoc num=3
Code: Select all
// Working with here for parameters passing
// Create some sections
create soma
access soma
create dend[3]
objref myClamp
// Define a few defaults
myDiam=1.25
myL=20
myAmp=0.1
myDel=100
myDur=500
tstop=1000
proc build_cell(){
printf("Building Cell: With myDiam=%g myL=%g myAmp=%g myDel=%g myDur=%g",myDiam,myL,myAmp,myDel,myDur)
connect dend[0](0), soma(1)
connect dend[1](0), dend[0](1)
connect dend[2](0), dend[1](1)
soma {
insert hh
diam=myDiam
L=myL
}
forsec "dend" {
insert hh
diam=myDiam
L=myL
}
soma myClamp=new IClamp(0.5)
myClamp.amp=myAmp
myClamp.del=myDel
myClamp.dur=myDur
}
proc set_buildpars(){
myDiam=$1
myL=$2
myAmp=$3
myDel=$4
myDur=$5
}
Code: Select all
$ /cygdrive/D/ProgramFiles/nrn58/bin/nrniv.exe here_ex.hoc - << here
> build_cell()
> set_buildpars(5,20,0.2,150,200)
> build_cell()
> here
Building Cell: With myDiam=0 myL=0 myAmp=0 myDel=0 myDur=0
Building Cell: With myDiam=5 myL=20 myAmp=0.2 myDel=150 myDur=200
Notice: dend[0](0) had previously been connected to parent soma(1)
Notice: dend[1](0) had previously been connected to parent dend[0](1)
Notice: dend[2](0) had previously been connected to parent dend[1](1)
Code: Select all
/cygdrive/c/nrn58/bin/nrniv file.hoc << here
. . .
As far as I can see these steps are unnecessary. Under cygwin using nrniv.exe neuron exits automatically. If you use neuron.exe you get the neuron GUI but not the one belonging to the context/scope/process (haven't figured that out yet) in which you executed the here script.If you want NEURON to exit automatically upon completion, make the first line of the hoc file
load_file("nrngui.hoc")
Otherwise you will need to include
quit()
as part of the here document.