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 › changed syntax for constructors?
Page Index Toggle Pages: 1
changed syntax for constructors?? (Read 462 times)
changed syntax for constructors??
Dec 3rd, 2007, 9:33pm
 
hi,
i tried to write a class and always got an error message

unexpected token: (

with the row of my constructor highlighted

after a while i tried an example from the processing book
and it didn`t work too.
i dont think that i made a syntax error,
has there anything changed in version 0135?

thanks for every answer
Re: changed syntax for constructors??
Reply #1 - Dec 3rd, 2007, 9:37pm
 
I seriously doubt anything has changed.

You'll need to post an example piece of code for us to be able to help any further.
Re: changed syntax for constructors??
Reply #2 - Dec 3rd, 2007, 9:47pm
 
hi Johng,

thanks for answering.
here`s the code

class LED{
 
 float x,y;
 
 int i;
 int diameter;
 int transparency = 255;
 int on,off;
 
 color light = color(on,transparency); ;
 color dark = color(off); ;
 
 boolean over = false;
 boolean pressed = false
   
 LED (float xp, float yp, int d, int an, int aus){
   
   x = xp;
   y = yp;
   diameter = d;
   on = an;
   off = aus;
 }
 
 void update(){
   
   if((mouseX >= x-diameter) && (mouseX <= x+diameter) &&
      (mouseY >= y-diameter) && (mouseY <= y+diameter){
       
        over = true;
   }
   else{over = false;}
 }
 
 void press(){
   
   if(over = true){
     
     pressed = true;
     return true;
   }
   else{return false;}
 }
 
 void display(){
       
   if(pressed = true){
     fill(light);      
     for(i= 255; i>0; i--){
       transparency = i;
     }
   }
   else{fill(dark);}
   
   noStroke();
   ellipse(x,y,diameter,diameter);
 }
}
   
 
maybe there are a lot of errors i´m relativ new to processing
Re: changed syntax for constructors??
Reply #3 - Dec 3rd, 2007, 10:15pm
 
Just a missing semi-column :

boolean pressed = false
                       ^^
 LED (float xp, float yp, int d, int an, int aus){

Re: changed syntax for constructors??
Reply #4 - Dec 3rd, 2007, 11:48pm
 
oh my god thank you
and i was so sure there is no syntax error

and how i expected there are lots of more bugs to fix
Page Index Toggle Pages: 1