odd result

Anything that doesn't fit elsewhere.
Post Reply
pfortier

odd result

Post by pfortier »

The following for loop works perfectly:

Code: Select all

objref rp
rp = new Random()
rp.poisson(3)
proc loadqueue() { local tm
	for (tm=rp.repick+1; tm<=20; tm=tm+rp.repick+1) print tm // for loop
}
loadqueue()
But the same for loop in a different context does not work:

Code: Select all

objref rec
soma rec = new ExpSyn(0.5)
objref rp
rp = new Random()
rp.poisson(3) 
objref ncq, nil
ncq=new NetCon(nil, rec, 0, 0, 0.1)
objref fih
fih = new FInitializeHandler("loadqueue()") 
proc loadqueue() { local tm
	for (tm=rp.repick+1; tm<=20; tm=tm+np.repick+1) ncq.event(tm) // for loop
}
This produces the error:

Code: Select all

/usr/bin/nrniv: parse error in hocodex.hoc near line 104
   for (tm=rp.repick+1; tm<=20; tm=tm+np.repick+1) ncq.event(tm) // for loop
                                         ^
I don't understand the problem!
pfortier

Post by pfortier »

The code now works fine. I deleted the line and rewrote exactly the same code and it works. I think this is the second time it happens to me. There must be some hidden character in the line. I use kate on linux.
pfortier

Post by pfortier »

It's not a hidden character!!! It works in the first instance as rp.repick but not in the second instance because I wrote np.repick (note "n" instead of "r"). Sorry for the waste of time and space.
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

Congratulations for finding that before someone else did. Typos are common, and it's real
easy to perceive what you "know" is on the page rather than what is actually there. It would
be nice if the hoc parser were smart enough to complain that np was not delcared to be an
objref. But with hoc, one is often one's own debugger.
Post Reply