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.
Page Index Toggle Pages: 1
Behavior (Read 724 times)
Behavior
Apr 7th, 2009, 6:29pm
 
Hello,

Noob to Processing here (wow whats new) Wink

Anyways, i have been noticing that when running a sketch, I will get a bunch of errors. I double check my code - and in some case it will be an exact copy from some examples. I will then run the sketch a second time, making no changes, and the code runs fine.

There has even been times that I had to run the code 3 or even 4 times before the errors go away and the code runs fine from then on.

Any Ideas?
Re: Behavior
Reply #1 - Apr 7th, 2009, 10:54pm
 
Mmm, now that's a vague error report if I even saw one!  Wink

What system do you use? What example is troublesome? What kind of error do you have? What do you mean by "exact copy"?
Re: Behavior
Reply #2 - Apr 8th, 2009, 8:49am
 
do you retype the whole thing for a 2nd or 3th try?

Also, are it errors in red color but yourscript still runs? Cause I almost always have that.
Re: Behavior
Reply #3 - Apr 8th, 2009, 9:43am
 
That sounds vaguely like a thing I ran into a while back:

A sketch isn't allowed to have a class with the same name as the name of the sketch.

Internally, Processing converts your sketch into a Java class with the same name as the sketch, so if you also have a class in your pde file with the same name, then there's a problem.

You can run into this unexpectedly in the following way.  Say, for example, you want to write a simulation of hitting a baseball.  You start Processing, and it gives you one of those "sketch_apr08a" kind of filenames.  You begin coding, and decide to encapsulate the properties of a baseball object into a class.  So you create:

class Baseball
{
...
}

Things are working fine.  Your code compiles and runs.  You decide to call it quits for the day, so you do a file->Save As, and choose the name "Baseball.pde".  Processing lets you do this with no trouble.

Next day, you load up Baseball.pde, and find that it won't run.  Now that your sketch has a different name, you have a name collision with the Baseball class you defined.  Goofy, but that's what happens.  Unfortunately, Processing's parser does not detect this situation and warn you about it in any meaningful way, so unless you know you'll be scratching your head for a long time over why your code that worked yesterday suddenly doesn't work today.
Re: Behavior
Reply #4 - Apr 8th, 2009, 9:56am
 
cloister wrote on Apr 8th, 2009, 9:43am:
A sketch isn't allowed to have a class with the same name as the name of the sketch.
Yes, it is likely if the OP pasted the code in a file he makes himself...
I have hit this problem myself, and was puzzle for a while too... Smiley
It is even more puzzling as it was OK in Processing 0135...  Roll Eyes
Re: Behavior
Reply #5 - Apr 11th, 2009, 8:32am
 
Hay thanks for the replies, for some reason I wasn't getting the notification that some one replied to my post.

I can't reproduce it all the time and once it runs without errors, it runs fine after that.

I have "copy + Paste" some of the included examples, run it and I get a bunch of red errors, Java this and Java that. If I run it again, it runs fine after that, with no changes on my part. This has also happened on some small ones I write my self, just playing trying to learn the syntax. I figure this is probably something I am doing wrong, but seems odd that it happens when I copy an example, either from the included example sketch's or copy+paste from the Language web site.

I am running Windows Vista.
Page Index Toggle Pages: 1