Hello everybody,
I'm getting a "parse error" with the following code and I don't understand why... I'm just confused about it...
Thanks for your help!
func didfire()
{
apcsum = 0
for i=0, nFascs-1
{//loops over all fascicles
for j=0, fasc.nAxons-1
{//loops over all axons in fascicle
for k=0, fasc.mye_axons[j].axonnodes-1
{//loop over all node in axon
fasc.mye_axons[j].node[k]
apcsum = apcsum + apc[k].n
}
if (apcsum >= ((fasc.mye_axons[j].axonnodes+1)/2))
{return 1}
else
{return 0}
}
}
}
Binary_output = didfire()
access fasc[0].mye_axons[0].node[0]
finitialize(v_init)
fcurrent()
Parse error
-
- Site Admin
- Posts: 6394
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
debugging code
Following the "teach a man to fish . . . " principle, here's a suggested strategy for
debugging your code.
General comments about parse errors:
The error message generally points to the cause. The erroneous line is printed
with a carat ^ that points at the location where the parser failed.
Common causes include invalid syntax, use of undefined names,
and using a variable of the wrong type.
That alone may be enough to help you find the problem.
Human nature being what it is, it is quite possible to stare at erroneous code all
day long and never see the mistake. When you find this happening, it's time to
resort to iterative testing. In pseudocode:
As a first step in this iterative exercise, it is often helpful to comment out the guts
of procs or funcs, and insert a stub statement that prints a message or returns
a fixed value.
debugging your code.
General comments about parse errors:
The error message generally points to the cause. The erroneous line is printed
with a carat ^ that points at the location where the parser failed.
Common causes include invalid syntax, use of undefined names,
and using a variable of the wrong type.
That alone may be enough to help you find the problem.
Human nature being what it is, it is quite possible to stare at erroneous code all
day long and never see the mistake. When you find this happening, it's time to
resort to iterative testing. In pseudocode:
Code: Select all
Comment out almost everything except for a tiny bit of code
that should produce a visible (printed or graphical) result.
Verify that your tiny bit works and produces the expected result.
REPEAT
uncomment a small part of that which was commented out
REPEAT
run a test (for parse errors, this just means have hoc parse it again)
if the uncommented code doesn't work (parse) as expected, revise it
UNTIL the revised stuff works properly
UNTIL EVERYTHING WORKS
of procs or funcs, and insert a stub statement that prints a message or returns
a fixed value.
-
- Site Admin
- Posts: 6394
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Manual? We don't read no stinking manuals!
Yeah, RTM also works. Forgot about that.ferron wrote:I found this by looking back at the documentation on the "if" statement.