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 › Wrong number of brackets
Page Index Toggle Pages: 1
Wrong number of brackets? (Read 953 times)
Wrong number of brackets?
Nov 12th, 2009, 11:28am
 
I get the error: Found one too many { characters without a } to match it.

I've checked my code for the brackets but I can't seem to find what I'm doing wrong. Could somebody please tell me what's wrong?




Switch one;
Switch two;
Switch three;
Switch four;
Switch five;
Switch six;
Switch seven;
Switch eight;
Switch nine;

void setup() {
 size(300,300);
 one = new Switch(0,0,100,false);
 two = new Switch(100,0,100,false);
 three = new Switch(200,0,100,false);
 four = new Switch(0,100,100,false);
 five = new Switch(100,100,100,true);
 six = new Switch(200,100,100,false);
 seven = new Switch(0,200,100,false);
 eight = new Switch(100,200,100,false);
 nine = new Switch(200,200,100l,false);
}

void draw()
{
 background(255);
 one.display();
 two.display();
 three.display();
 four.display();
 five.display();
 six.display();
 seven.display();
 eight.display();
 nine.display();  
}
Re: Wrong number of brackets?
Reply #1 - Nov 12th, 2009, 11:32am
 
not in this part of the code. seems to be ok.
Re: Wrong number of brackets?
Reply #2 - Nov 12th, 2009, 11:36am
 
Switch 9 is declared with a long (100l) -- might be a typo?

You must have more code; you have a Switch class, for instance...the curly braces in this code are fine.

By the way, when you have a list of similar objects being updated with a similar routine, you're begging for an array!  It will make your life much easier.

Switch[] switches = new Switch[9];
// keep switch creation code, e.g.:
switches[0] = new Switch(0,0,100,false);
// then, to update, in draw() :
for (int i=0;i<switches.length;i++){
 switches[i].display();
}
Re: Wrong number of brackets?
Reply #3 - Nov 13th, 2009, 1:18am
 
Maybe the Switch class is on another tab?  It's worth noting that IIRC Processing essentially treats additional tabs as an extension of the first, so a missing brace in one of those could be the problem...
Page Index Toggle Pages: 1