hoc pointer to variable

Anything that doesn't fit elsewhere.
Post Reply
pfortier
Posts: 47
Joined: Thu Apr 20, 2006 8:02 am
Location: University of Ottawa

hoc pointer to variable

Post by pfortier » Wed Oct 13, 2010 1:22 pm

I'd can't seem to get Pointer(&x) to work. I tested

objref arrow
age=33
arrow = Pointer(&age)

but it doesn't work. I'm testing it to see if I can use it. Ultimately, I'm trying to find a way to have an array with elements that point to different variables (defined in hoc or mod files) so that I can loop through the array and call k=arrow.val or arrow.val=k. In C, it would be something like (my C is a bit rusty)

double * arrow[12]
double age=33
arrow[0]=&age

ted
Site Admin
Posts: 5740
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: hoc pointer to variable

Post by ted » Thu Oct 14, 2010 11:08 am

I'm trying to find a way to have an array with elements that point to different variables (defined in hoc or mod files) so that I can loop through the array and call k=arrow.val or arrow.val=k. In C, it would be something like (my C is a bit rusty)

double * arrow[12]
double age=33
arrow[0]=&age

Presumably you have some larger goal that you wish to achieve through the technique of using an array of pointers to iterate through a collection of variables. Unfortunately, this technique is not available to you in hoc, because:
1. hoc doesn't have a * operator. POINTER is an NMODL keyword, not a hoc keyword.
2. hoc's & is used for only two purposes: to pass a scalar argument by reference to a proc or func, and to linking a hoc scalar to a POINTER variable in an NMODL-specified density mechanism, point process, or artificial spiking cell

That said, there are many ways to skin a cat, so I am sure there is some other way to achieve your larger goal. Without knowing anything about that goal, I can't get into particulars.

Post Reply