First I made an NMODL function that is callable from hoc:

Code: Select all

```
NEURON {
SUFFIX nothing
}
FUNCTION get_x_pos1(binSizeX) {
get_x_pos1 = binSizeX/2.0
}
```

Code: Select all

```
VERBATIM
# include <stdlib.h>
# include <stdio.h>
# include <math.h>
ENDVERBATIM
NEURON {
SUFFIX nothing
}
VERBATIM
extern double* vector_vec();
extern int vector_capacity();
extern void* vector_arg();
ENDVERBATIM
VERBATIM
static double get_x_pos2 (double binSizeX) {
double pos;
pos = binSizeX/2.0;
return pos;
}
static double testconn (void* vv) {
double finalconn, ny, *x, *y;
/* Get hoc vectors into c arrays */
finalconn = vector_instance_px(vv, &x); // x is an array corresponding
// to the placeholder vector
// of connections to make
ny = vector_arg_px(1, &y);
/* Parameters from the param array
y[0] binSizeX
*/
x [0] = get_x_pos1(y[0]);
x [1] = get_x_pos2(y[0]);
return finalconn;
}
ENDVERBATIM
PROCEDURE install_testconn () {
VERBATIM
install_vector_method("testconn", testconn);
ENDVERBATIM
}
```

Code: Select all

```
load_file("nrngui.hoc")
install_testconn()
binSizeX = 10.00
print "from hoc, use function of interest: ", get_x_pos1(binSizeX)
objref mypos, params
mypos = new Vector(2)
params = new Vector(1)
params.x[0] = binSizeX
mypos.testconn(params)
print "from NMODL, use function of interest: ", mypos.x[0], ", use comparison: ", mypos.x[1]
quit()
```

Not sure how to fix my "function of interest" definition so it works in NMODL? Note that "binSizeX" is an integer in this example but that may not be the case in my working code. Thanks!from hoc, use function of interest: 5

from NMODL, use function of interest: 1.0761011e+09 , use comparison: 5