A code that works on the interpreter but not in a hoc file!

Anything that doesn't fit elsewhere.
Post Reply
porio

A code that works on the interpreter but not in a hoc file!

Post by porio »

Hi everybody!

I have this little piece of code within a hoc file:

Code: Select all

	objref rvm[n-1]
	for m=0, n-2 rvm[m] = new RangeVarPlot("v")
	for m=0, n-2 term[m+1] rvm[m].begin(0)
	for m=0, n-2 axon rvm[m].end(1)
	for m=0, n-2 sgraph.addobject(rvm[m], m+2, 2)
Whenever I run the file, it gets interrupted with the message:

nrniv: rvm not an array variable
in C:/(...blahblahblah...)/longIclamp.hoc near line 128
for m=0, n-2 rvm[m] = new RangeVarPlot("v")

HOWEVER, I can comment the block, get the hoc file loaded and then type each command in the interpreter and they get correctly executed, without any error message! (I have already tried putting the block at the end of the hoc file, so there are no commands that have to be executed before).
How can that be possible?

Some background: the term[0] section has its RangeVarPlot defined in other part of the code. The code that I am presenting here is within a if(n>1) block (n being the number of term sections, and will be normally 4)

Regards
Raj
Posts: 220
Joined: Thu Jun 09, 2005 1:09 pm
Location: Groningen, The Netherlands
Contact:

Post by Raj »

Your hoc-code in the original file seems to be within parentheses and probably even in a function. If so you have to make sure that rvm exist before, you can then later reallocate it at a larger/ not predefined size.

Sp probably adding:

Code: Select all

objref rvm
outside of a block or function will solve your problem.
Post Reply