Can I force an assigned variable to be an integer in NMODL

NMODL and the Channel Builder.
Post Reply
Raj
Posts: 220
Joined: Thu Jun 09, 2005 1:09 pm
Location: Groningen, The Netherlands
Contact:

Can I force an assigned variable to be an integer in NMODL

Post by Raj »

I wrote the NMODL file below, which defines an artificial cell which counts spikes/events of all the NetCons connected to it and fires when it reaches a predefined value. The firing of this cell is used to halt the simulation and subsequently save the results to file.
It would be neat if the assigned variables `count' and the parameter `stopcount' were unsigned integers. Is there a way to achieve that?

Code: Select all

: networkcounter.mod
NEURON {
        ARTIFICIAL_CELL NetCounter
        RANGE count, stopcount
}

PARAMETER {
	stopcount=1e9 (1) <0,1e9>
}

ASSIGNED {
	count (1)
}

INITIAL {
	count=0
}

NET_RECEIVE(w) {   
    count=count+1
    if(count >= stopcount){
        net_event(t)    
    }	
}
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: Can I force an assigned variable to be an integer in NMO

Post by hines »

The only way to declare non-double variables is within a VERBATIM block.
The most general idiom (works on both 32 and 64 bit machines)
for getting your own c structures matched up with the mechanism
instances to use :

NEURON { POINTER ptr }

VERBATIM
typedef stuct {
...
} MyStruct;
#define MYCAST MyStruct** ms = (MyStruct**)(&(_p_ptr))
ENDVERBATIM

See nrn/src/nrnoc/pattern.mod for an elaborated example of this idiom and how to use it.
Of course the 'ptr' variable above is useless as a direct variable in hoc and the only access
should be through function calls to set and get fields of a MyStruct instance.
Post Reply