Notes on VERBATIM

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

Notes on VERBATIM

Post by mctavish » Wed Mar 04, 2009 12:41 pm

I was unable to find documentation explaining several issues with VERBATIM in MOD files. Through the response at viewtopic.php?f=16&t=1512 and exploring MOD files at ModelDB, I thought I'd provide a brief note on what I've learned. (Please let me know if I'm incorrect with any of the following, or other pointers).

1) NMODL variables are accessible to VERBATIM blocks by prepending "_l". (Note: That's an underscore and lowercase "L").

2) VERBATIM can return from a function by returning "_lfunctionName".

Both of these points are illustrated in the following example

Code: Select all

FUNCTION addargs(arg1, arg2) {
   VERBATIM {
       _laddargs = _larg1 + _larg2;
   }
   ENDVERBATIM
}
3) Non "double" arguments can be passed and read through arg-reading functions.
If you write a PROCEDURE or FUNCTION and pass doubles, you can simply put them in the method declaration:

Code: Select all

PROCEDURE myfun(arg1, arg2) { }
If the arguments are not doubles, then you have to keep the parentheses empty and call neuron-defined arg functions. Several useful functions are found in nrn/src/ivoc/oc2iv.h and nrn/src/nrniv/nrnoc2iv.h. I even found one in nrn/src/ivoc/ocfile.cpp for passing in files.

Code: Select all

PROCEDURE myFileFunction() {
   VERBATIM {
      if (ifarg(1)) {  // FILE * object passed in from hoc
         FILE* file = hoc_obj_file_arg(1);
         // Do stuff with the file
      }
   }
   ENDVERBATIM
}

Post Reply