# My functions are giving me an error, wanting a semicolon somewhere

**URL:** https://discourse.processing.org/t/my-functions-are-giving-me-an-error-wanting-a-semicolon-somewhere/32961
**Category:** Coding Questions
**Created:** [October 20, 2021, 5:14pm UTC](https://discourse.processing.org/t/my-functions-are-giving-me-an-error-wanting-a-semicolon-somewhere/32961 "2021-10-20T17:14:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Timeless\_Mage](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@Timeless\_Mage](https://discourse.processing.org/u/Timeless_Mage)
#### Post date: [October 20, 2021, 5:14pm UTC](https://discourse.processing.org/t/my-functions-are-giving-me-an-error-wanting-a-semicolon-somewhere/32961/1 "2021-10-20T17:14:05Z")

</div>

These functions are giving me an error, asking for a semicolon, but when I add it, it doesn’t fix the error.  
\<\>  
int arrayTotal(int array[]) {  
int total= 0;  
for (int i= 0; i\<array.length; i++) {  
total+=array[i];  
}  
return total;  
}

void setXandYCoords(Die dice[]) {  
for (int i= 0; i\<dice.length; i++) {  
int x= (dice.length/2)-i;  
x\*=-1;  
dice[i].setCoords(SCREEN\_WIDTH+(x\*(dice[i].getDieFace().width+(dice[i].getDieFace().width/2))),(SCREEN\_HEIGHT/2)-(dice[i].getDieFace().height/2));  
}  
return null;  
}  
}  
\</\>

---

<div class="post-metadata">

### Author: ![gitanerie](https://avatars.discourse-cdn.com/v4/letter/g/b5a626/32.png) [@gitanerie](https://discourse.processing.org/u/gitanerie)
#### Post date: [October 20, 2021, 7:09pm UTC](https://discourse.processing.org/t/my-functions-are-giving-me-an-error-wanting-a-semicolon-somewhere/32961/2 "2021-10-20T19:09:21Z")

</div>

> [@Timeless\_Mage](#):
>
> dice[i].setCoords(SCREEN\_WIDTH+(x\*(dice[i].getDieFace().width+(dice[i].getDieFace().width/2))),(SCREEN\_HEIGHT/2)-(dice[i].getDieFace().height/2));

When processing tells you that you have a missing semicolon where you clearly doesn’t, it generally means that you have something like a missing bracket.

In your case, you’re missing a ‘)’ in this line. I believe you should add it after the ~.getDieFace().width/2

---

<div class="post-metadata">

### Author: ![Timeless\_Mage](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@Timeless\_Mage](https://discourse.processing.org/u/Timeless_Mage)
#### Post date: [October 21, 2021, 5:29pm UTC](https://discourse.processing.org/t/my-functions-are-giving-me-an-error-wanting-a-semicolon-somewhere/32961/3 "2021-10-21T17:29:09Z")

</div>

I tried that, and it is still giving me an error. Also, for arrayTotal function, it is still giving me an error. Any thoughts?  
`int arrayTotal(int array[]) { int total= 0; for (int i= 0; i<array.length; i++) { total+=array[i]; } return total; }`

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 21, 2021, 5:39pm UTC](https://discourse.processing.org/t/my-functions-are-giving-me-an-error-wanting-a-semicolon-somewhere/32961/4 "2021-10-21T17:39:49Z")

</div>

I guess the error is somewhere else

please post entire code

> [@Timeless\_Mage](#):
>
> `int arrayTotal(int array[]) { int total= 0; for (int i= 0; i<array.length; i++) { total+=array[i]; } return total; }`

```auto
int arrayTotal( int array[] ) { 
   int total= 0; 
   for (int i= 0; i<array.length; i++) { 
        total+=array[i]; 
   } 
   return total; 
}

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 21, 2021, 5:44pm UTC](https://discourse.processing.org/t/my-functions-are-giving-me-an-error-wanting-a-semicolon-somewhere/32961/5 "2021-10-21T17:44:32Z")

</div>

> [@Timeless\_Mage](#):
>
> dice[i].setCoords(SCREEN\_WIDTH+(x\*(dice[i].getDieFace().width+(dice[i].getDieFace().width/2))),(SCREEN\_HEIGHT/2)-(dice[i].getDieFace().height/2));

**In general:**

You have a class Die

In this line, you are referring 3 times to the dice[i]. (apart from the initial one).  
This calls for making the line a function (method) within the class:

```auto
void setCoordsForScreen() {
   setCoords(
       SCREEN_WIDTH+(x*(getDieFace().width+(getDieFace().width/2))), 
       (SCREEN_HEIGHT/2)-(getDieFace().height/2)
     ); 
}

```
