Installing new function OR Passing string as argument

NMODL and the Channel Builder.
Post Reply
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Installing new function OR Passing string as argument

Post by mctavish »

I am trying to read the contents of a user-specified file into a 3D table. I understand I can do this in HOC through Vectors and Lists, but that seems like it might be slow. (I need to reference various locations in this table quite frequently after it is built).

I am therefore trying to write NMODL code that stores the 3D array and has a function to get appropriate values. I see how I can create some 3D array (or 1D with fast offset calculations) in NMODL, but I do not see where I can code a FUNCTION/PROCEDURE to accept a string that will serve as the file to read. Allowable parameters seem to be doubles. Is that true? (I'm also wanting to label instances of my object and have a "name" field).

With one approach, I can place my function (with char* parameter) entirely in a VERBATIM statement, which will compile, but hoc does not see the function. If I pursue this route, I need to know how to properly install the method so that it is available in hoc. (I guess something following Lytton's "install_vector_method").

Using the FUNCTION/PROCEDURE approach, the parameter has to be a double. Is there a way to cast the string from HOC, properly to a double pointer?

Thanks

hines
Site Admin
Posts: 1596
Joined: Wed May 18, 2005 3:32 pm

Re: Installing new function OR Passing string as argument

Post by hines »

I am trying to read the contents of a user-specified file into a 3D table.
I'd use either Python or, in hoc,

Code: Select all

double x[a][b][c]
But if you want to do it in nmodl, by means of VERBATIM you can use all the functions in c code.
nrn/src/ivoc/oc2iv.h and nrn/src/nrniv/nrnoc2iv.h give useful lists. In particular, the one you want
to read a string arg is

Code: Select all

extern char* gargstr(int);

mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Re: Installing new function OR Passing string as argument

Post by mctavish »

Thanks Michael.

Post Reply