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 › Very first problem with Processing :(
Page Index Toggle Pages: 1
Very first problem with Processing :( (Read 7214 times)
Very first problem with Processing :(
Jan 10th, 2006, 2:52pm
 
Hello everyone !

I'm very new to Processing as i'm new here too.
I readed 2 big tutorials so now it's time to try my first own program Smiley

but as soon i started as soon i meet a problem i realy don't understand :/

I wrote a very simple one :

-------------------------------

PImage pieddroit;
pieddroit = loadImage("pieddroit.gif");

void setup() {
 size(400, 400);
}

void draw()
{
 background(0);
 image(pieddroit, 50, 50, 30, 56):
}


---------------------------------------



But as soon i clikc on Play it give me an
"unexpected token:void"

uh ??
i can't understand it.
I didn't forget any {} or () so what's the problem ? when i look at working exemples it seem to me it's writent exactly that same no ? Sad

thx to help me Smiley


P.S :
btw... is there an irc channel about Processing to go to ask small and fast questions like this one ?
Re: Very first problem with Processing :(
Reply #1 - Jan 10th, 2006, 3:07pm
 
Oops... sorry i found by myself Tongue

It finally worked when i changed the "loadImage" line to put it in the Setup. Seem that the order is important.

anyway if someone have information about a IRC channel i'm still interested Smiley as i 'll probably have a new question to ask soon or later Wink


C you !
Re: Very first problem with Processing :(
Reply #2 - Jan 10th, 2006, 7:04pm
 
New problem Sad

I begin to think the Processing error detection is quite unclear :/
I have a new "unexpected token" error but it really don't explain what's the problem is about.


So here is the new problem... my program was working few time ago but i added some new lines and now i have an
unexpected token : if


Here is my program (it's far from be finished) :

Quote:
// Traces de pas sur le parcours de la souris

PImage pieddroit;
int num = 60;                           // Nombre de prises de positions de la souris
int nPd = 6;
int incr = 0;
float mx[] = new float[num];
float my[] = new float[num];
float cPx[] = new float[nPd];
float cPy[] = new float[nPd];
float posxPD, posyPD, wP, hP, xD, yD, angle;

void setup() {
 size(400, 400);
 pieddroit = loadImage("pieddroit.gif");
 wP = 30;
 hP = 56;
}

void draw()
{
 background(0);

 for(int i=1; i<num; i++) {           // Décalage les valeurs de l'array mx et my
   mx[i-1] = mx[i];
   my[i-1] = my[i];
 }

 mx[num-1] = mouseX;                 // Inscrit la position de la souris dans le tableau array
 my[num-1] = mouseY;

 xD = mx[num-1]-mx[num-5];           // Calcul de l'angle
 yD = my[num-1]-my[num-5];
 angle=atan2(yD,xD);
 incr++
 if (incr > 9) {
   incr = 0;
   cPx[nPd] = mx[num-1];
   cPy[nPd] = my[num-1];
   for(int i=1; i<nPd; i++) {        // Décale les valeurs de l'array CPx et cPy
       cPx[i-1] = cPx[i];
       cPy[i-1] = cPx[i];
   }
 }

 for(int i=0; i<nPd; i++) {         // Positionnne tous les pieds pour l'instant t
   translate(cPx[i], cPy[i]);
   rotate(angle);
   image(pieddroit, -wP/2, -hP/2, wP, hP);
 }
}





Thx for any help :/
Re: Very first problem with Processing :(
Reply #3 - Jan 10th, 2006, 7:14pm
 
I think this one is because there is no semicolon at the end of incr++ and so the compiler doesn't expect to suddenly hit an if. If you just make it "incr++;" it should work.
Re: Very first problem with Processing :(
Reply #4 - Jan 10th, 2006, 7:14pm
 
always, if the error isn't obviuos, check also the lines
before the error.

there is just missing a ";" in the line before the "if".
Re: Very first problem with Processing :(
Reply #5 - Jan 10th, 2006, 7:15pm
 
There's only one if in your code as far as I can see. And the statement above the if "incr++" needs to get a semicolon at the end.
So what java wants to tell you is that you can't put an if after a ++statement. You need to finish the statement with a semicolon.
Re: Very first problem with Processing :(
Reply #6 - Jan 10th, 2006, 9:06pm
 
?!!!

Cheesy
How could i miss that ?? pffff

I'm sorry Tongue i readed all my lines many times and didn't see that. Shame on me :blush:

thanks a lot for all your answers that was so fast Wink
Page Index Toggle Pages: 1