Can't find the missing curly bracket

I can’t find the error associated with <Syntax Error - Missing right curly bracket “}”> The problem is in the last few lines of code. Lines underscored by the debugger are indicated by //!! which I inserted after pasting here. I’m a beginner with this compiler and have yet to get the nuances of the error messages. The formatting I use takes a few more lines, but it helps me to see problems like this.

int hideColor = (#656565);
int x = 80;
int y = 80;
int red = #FF0000;
int green = #00FF00;
int yellow = #FFFF00;
int lightGreen = #66FF66;
int white = #FFFFFF;
int black = #000000;
int boxMaxX;
int boxMaxY;
int boxMinX;
int boxMinY;
int colorValue;
float Xpos;
float Ypos;

void setup()
  background (100);
//setup initial image
  rect (x, y, 30, 22);
  line(x, y-11, 80, y-40);
//rect limits
  boxMaxX = x + 15;
  boxMinX = x - 15;
  boxMaxY = y + 11;
  boxMinY = y - 11;
void draw ()
  rect (x, y, 30, 22);

void mouseClicked()
  if ((mouseY > (y - 11)) && (mouseY < (y + 11)) && (mouseX < (x + 15)) && (mouseX > (x - 15)))
  {   //!!
    If (colorValue == lightGreen)
      colorValue = Red;
    else  //!!
      colorValue = lightGreen;
}  //!!

Your second if in mouseClicked() is not if, it’s If.

That might be the problem.


You’ve also got red in one place and Red in another. The image is black so I don’t think your setup rect fill is being applied. …Or it is being applied and draw() is wrecking it because initially it doesn’t know the value of colorValue.

Bad IF. Fixed it. Once the If was fixed the Red became obvious. Works fine.

This is what I see when running your code in Java mode on a Mac after making the changes that you described. The rectangle is black and stays black no matter how many times I click on it.


I hadn’t added any activity to the code - I was befuddled by the error message. I’ve pretty much become accustomed to odd error messages. The screen is now populated with 55 of them, all working just fine. All these ‘levers’ do is set a bit on a virtual memory board. Those bits and others are red by the logic which sets bits on other boards that feed lever locks and signals. This is all eye candy so I can see what the logic is doing. Based on the prototype installation, when the dust finally settles I expect between 10,000 and 15,000 lines of logic code that will be installed on 4 or 5 Arduino MEGA 0256 microprocessors.

@hacketet Sounds like a nice project. As far as my problem with the code I was alluding to the fact that you intended for the slider thumb to be lightGreen at startup, but it winds up being black on my system. On the first pass through draw() it is turned to black because you did not initialize ‘colorValue’. Your app thinks the value is zero because it wasn’t initially set, hence it makes the fill black even though it was made lightGreen in the setUp(). After clicking on the thumb several times the app finally gets a red or green colorValue and it starts working. The fix is simple; add colorValue = #66FF66; to the setUp() and it will start off being green the way you intended. Good luck with your project.

Thanks , will modify the startup