# Can't find the missing curly bracket

**URL:** <https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152>\
**Category:** Beginners\
**Created:** [October 29, 2021, 5:03am UTC](https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152 "2021-10-29T05:03:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hacketet](https://avatars.discourse-cdn.com/v4/letter/h/2bfe46/32.png) [@hacketet](https://discourse.processing.org/u/hacketet)\
**Post date:** [October 29, 2021, 5:03am UTC](https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152/1 "2021-10-29T05:03:05Z")

</div>

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.

```auto
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()
{
  fullScreen();
  background (100);
//setup initial image
  rectMode(CENTER);
  noStroke();
  fill(lightGreen);
  rect (x, y, 30, 22);
  stroke(black);
  strokeWeight(6);
  line(x, y-11, 80, y-40);
//rect limits
  boxMaxX = x + 15;
  boxMinX = x - 15;
  boxMaxY = y + 11;
  boxMinY = y - 11;
}
void draw ()
{
  rectMode(CENTER);
  noStroke();
  fill(colorValue);
  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;
    }
  }
} //!!

```

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [October 29, 2021, 6:50am UTC](https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152/2 "2021-10-29T06:50:08Z")

</div>

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

That might be the problem.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 29, 2021, 8:10am UTC](https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152/3 "2021-10-29T08:10:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hacketet](https://avatars.discourse-cdn.com/v4/letter/h/2bfe46/32.png) [@hacketet](https://discourse.processing.org/u/hacketet)\
**Post date:** [October 29, 2021, 2:01pm UTC](https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152/4 "2021-10-29T14:01:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 29, 2021, 4:00pm UTC](https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152/5 "2021-10-29T16:00:10Z")

</div>

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.

![output](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/4bbda3775cb1e4e47e63808cbb556a83c529b056.png)

---

<div class="post-metadata">

**Author:** ![hacketet](https://avatars.discourse-cdn.com/v4/letter/h/2bfe46/32.png) [@hacketet](https://discourse.processing.org/u/hacketet)\
**Post date:** [October 30, 2021, 1:54pm UTC](https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152/6 "2021-10-30T13:54:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [October 30, 2021, 3:24pm UTC](https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152/7 "2021-10-30T15:24:04Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![hacketet](https://avatars.discourse-cdn.com/v4/letter/h/2bfe46/32.png) [@hacketet](https://discourse.processing.org/u/hacketet)\
**Post date:** [October 30, 2021, 3:51pm UTC](https://discourse.processing.org/t/cant-find-the-missing-curly-bracket/33152/8 "2021-10-30T15:51:32Z")

</div>

Thanks , will modify the startup
