Diagnosing and fixing non-ASCII characters in a hoc file

Anything that doesn't fit elsewhere.
Post Reply
blop

Diagnosing and fixing non-ASCII characters in a hoc file

Post by blop »

Hi Ted,

if I use the first 3 lines of code

Code: Select all

objref pre, nc
pre = new NetStim()
pre.noise = 1  // for negexp ISIs
that you quoted in
How to connect ARTIFICIAL_CELL with real cell
https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=967
I obtain the following error:
/Applications/NEURON-6.0/nrn/i386/bin/nrniv.app/Contents/MacOS/nrniv: parse error
in main.hoc near line 16
pre.noise = 1? // for negexp ISIs
^
(note that the question mark is not from me...)
I have no clue what this error means and how to solve it.

With pre.start or pre.interval I obtain the same error, of course, as if the NetStim class wasn't known.
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

Very strange. Is that the entire program that you passed to hoc, or is it part of something
else? If so, what?
blop

Post by blop »

Well, before that, I just create a cell from a template file, but this worked fine so far...

Code: Select all

	xopen("myneuron.tem")			// cell template
	objref LP
	LP = new myneuron()
	
	objref pre, nc 
	pre = new NetStim() 
	pre.noise = 1  // for negexp ISIs 
blop

Post by blop »

note: if I comment the pre.noise line, the program runs fine
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

Not enough information for me to tell what's happening. Maybe if you send me
ted dot carnevale at yale dot edu
both the file
myneuron.tem
and the hoc file that contains your
xopen( etc.
statements, I will be able to diagnose the problem and tell you how to fix it.
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

The problem was caused by a non-ASCII character embedded in the hoc file that blop
was testing.
od -a test.hoc produced this output:

Code: Select all

0000000  ht   o   b   j   r   e   f  sp   p   r   e   ,  sp   n   c  sp
 . . .
0000060   e  sp   =  sp   1   B  sp  sp   /   /  sp   f   o   r  sp   n
where the B in line 060 was suspicious, and od -x test.hoc confirmed this suspicion
(the carets ^ just below the bad hex code were added by me):

Code: Select all

0000060 2065 203d c231 20a0 2f2f 6620 726f 6e20
                  ^^
0xc2 (hexadecimal) = 194 (decimal), i.e. lies outside the ASCII character set, which stops at
0x7f (127 decimal).

It's not clear how it got there, and it's also a bit puzzling that it wasn't in the code that blop
posted above. But it certainly was in the hoc file that blop sent me, which was produced
with TextWrangler.

So the take-home lesson is how to diagnose and fix such problems on the rare occasions
when they occur.

The question mark in the error msg on blop's Mac is in exactly the same place as the
non-ASCII character in the hoc file. Under Linux, the error message is

Code: Select all

/usr/local/nrn/i686/bin/nrniv: syntax error
 in test.hoc near line 3
        pre.noise = 1  // for negexp ISIs 
               ^
i.e. not so nice because the exact location of the bad character isn't flagged. But in
either case, the fix is the same: get rid of the bad character. The quick and dirty way
is just to delete the entire line (or just the bad character if you can identify it) and retype it.
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

A new, meaningful error message!

Post by ted »

Michael Hines informs me that
"any version subsequent to
NEURON -- VERSION 6.1.961 (1895) 2007-11-26
will print the error message:"

Code: Select all

/home/hines/neuron/nrnmpi/x86_64/bin/nrniv: syntax error
 in test.hoc near line 3
character \302 at position 14 is not printable
        pre.noise = 1  // for negexp ISIs 
               ^
That makes it easy to identify and fix such problems.
Post Reply