We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Error Messages, Examples
Page Index Toggle Pages: 1
Error Messages, Examples (Read 1331 times)
Error Messages, Examples
Aug 14th, 2009, 6:16am
 
1. Is there place where all error message from prcessing are displayed, collected?
e.g. what does "unexpected token" mean?

2. under the brown(?) error message there is a black window with red error messages saying:

e.g. processing.app.debug.RunnerException: unexpected token: 0
     at processing.app.Sketch.preprocess(Sketch.java:1362)
     at processing.app.Sketch.build(Sketch.java:1473)
     at processing.app.Sketch.compile(Sketch.java:1172)
     at processing.app.Editor.handleRun(Editor.java:1574)

What does "Editor.java:1574" mean?

3. I was trying to run the following example:

http://processing.org/reference/draw_.html

float yPos = 0.0;

void setup() {
 size(200, 200);
 frameRate(30);
}

void draw() {
 background(204);
 yPos = yPos - 1.0;
 if(yPos  0) {
   yPos = height;
 }
 line(0, yPos, width, yPos);
}

it gave me this error message:




processing.app.debug.RunnerException: unexpected token: 0
     at processing.app.Sketch.preprocess(Sketch.java:1362)
     at processing.app.Sketch.build(Sketch.java:1473)
     at processing.app.Sketch.compile(Sketch.java:1172)
     at processing.app.Editor.handleRun(Editor.java:1574)
     at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:318)
     at java.awt.Component.processMouseEvent(Component.java:5599)
     at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
     at java.awt.Component.processEvent(Component.java:5367)
     at java.awt.Container.processEvent(Container.java:2010)
     at java.awt.Component.dispatchEventImpl(Component.java:4068)
     at java.awt.Container.dispatchEventImpl(Container.java:2068)
     at java.awt.Component.dispatchEvent(Component.java:3903)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3933)
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
     at java.awt.Container.dispatchEventImpl(Container.java:2054)
     at java.awt.Window.dispatchEventImpl(Window.java:1801)
     at java.awt.Component.dispatchEvent(Component.java:3903)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:2
69)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190
)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
processing.app.debug.RunnerException: unexpected token: 0
     at processing.app.Sketch.preprocess(Sketch.java:1362)
     at processing.app.Sketch.build(Sketch.java:1473)
     at processing.app.Sketch.compile(Sketch.java:1172)
     at processing.app.Editor.handleRun(Editor.java:1574)
     at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:318)
     at java.awt.Component.processMouseEvent(Component.java:5599)
     at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
     at java.awt.Component.processEvent(Component.java:5367)
     at java.awt.Container.processEvent(Container.java:2010)
     at java.awt.Component.dispatchEventImpl(Component.java:4068)
     at java.awt.Container.dispatchEventImpl(Container.java:2068)
     at java.awt.Component.dispatchEvent(Component.java:3903)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3933)
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
     at java.awt.Container.dispatchEventImpl(Container.java:2054)
     at java.awt.Window.dispatchEventImpl(Window.java:1801)
     at java.awt.Component.dispatchEvent(Component.java:3903)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:2
69)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190
)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

thank you
l.
Re: Error Messages, Examples
Reply #1 - Aug 14th, 2009, 7:02am
 
An unexpected token error is basically a syntax error. It just means that the system encountered a piece of code that it wasn't expecting yet, i.e. it was looking for a semicolon or a right parenthesis or a right bracket before it was expecting some other piece of code.

In your case, you forgot some code within your if statement. You are trying to call:
Code:

if(yPos 0){
    yPos = height;
}


Your are missing the "is equal to" symbol in the middle of your expression there. It should be:
Code:

if(yPos == 0){
    ...

So the system encountered the zero right after yPos, and that doesn't make sense. So the zero is your unexpected token, because it was looking for some comparison operation to happen first. Also, if you try to run your original code, notice that Processing highlights the line of code that caused the problem. It also tells you what piece of code caused the problem within that line. So it should say "Unexpected token: 0" showing you that it was the zero that was the problem.
Re: Error Messages, Examples
Reply #2 - Aug 14th, 2009, 7:11am
 
OK...  regarding:

Code:
float yPos = 0.0;

void setup() {
size(200, 200);
frameRate(30);
}

void draw() {
background(204);
yPos = yPos - 1.0;
if(yPos  0) {
  yPos = height;
}
line(0, yPos, width, yPos);
}



When it displays an error message Processing highlights the line that's causing the problem.  Most of the time this is where you have to concentrate you attention.  in your case it's:

if(yPos  0) {

So why is '0' an unexpected token  The key point here is 'unexpected'.  In a condition you need to specify the comparison you're trying to make.  Do you want to check that 'yPos' is equal to 0; that it's not equal to 0, or maybe that it's greater or less than 0  Processing expects an operator after the variable, instead it gets '0'...  This is unexpected; hence the error.

Check out the 'Relational operators' in the reference.

The only time you don't have to specify an operator is when checking whether a Boolean returns true:

Code:
if (myBoolean) {
 //
}


though notice that you don't need to include 'true' anywhere for this to work.
Re: Error Messages, Examples
Reply #3 - Aug 14th, 2009, 10:22am
 
Thanks a lot!
I will try to understand that Smiley

l.
Re: Error Messages, Examples
Reply #4 - Aug 15th, 2009, 8:42am
 
Feel free to ask more questions if you don't. We don't mind. We were all beginners once!
Smiley
Page Index Toggle Pages: 1