# Looks like your mixing static and active modes

**URL:** <https://discourse.processing.org/t/looks-like-your-mixing-static-and-active-modes/12137>\
**Category:** Beginners\
**Created:** [June 17, 2019, 8:03pm UTC](https://discourse.processing.org/t/looks-like-your-mixing-static-and-active-modes/12137 "2019-06-17T20:03:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![er45](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/er45/32/5594_2.png) [@er45](https://discourse.processing.org/u/er45)\
**Post date:** [June 17, 2019, 8:03pm UTC](https://discourse.processing.org/t/looks-like-your-mixing-static-and-active-modes/12137/1 "2019-06-17T20:03:16Z")

</div>

I cannot get processing three to put text on the screen. I get "looks like your mixing static and active modes. Can any one help? Thanks!  
Ed

Code:

```auto
int rainfall[] = {2, 3, 5, 1, 4, 6, 7, 2, 1};

float average(int[] data) {
   int sum1 = 0;
   for(int i = 0; i < data.length; i++) {
      sum1 += data[i]; 
   }
   
   return (float)(sum1 / data.length);
}

float avgRain = average(rainfall);

textSize(12);
fill(0);
text(avgRain, 10, 20);

```

---

<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:** [June 17, 2019, 8:19pm UTC](https://discourse.processing.org/t/looks-like-your-mixing-static-and-active-modes/12137/2 "2019-06-17T20:19:48Z")

</div>

The problem is that you have some code that is not inside a function.

Either all your code needs to be inside functions (like setup()) and draw()), or you should not use functions at all (in which case your code is just a list of instructions).

Because you have a function (average()), you should put your draw code into draw():

```auto
int rainfall[] = {2, 3, 5, 1, 4, 6, 7, 2, 1};
float avgRain;

void setup(){
  size(400,400);
  avgRain = average(rainfall);
}

void draw(){
  background(255);
  textSize(12);
  fill(0);
  text(avgRain, 10, 20);
}

float average(int[] data) {
  int sum1 = 0;
  for(int i = 0; i < data.length; i++) {
    sum1 += data[i];
  }
  return (float)(sum1 / data.length);
}

```

---

<div class="post-metadata">

**Author:** ![er45](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/er45/32/5594_2.png) [@er45](https://discourse.processing.org/u/er45)\
**Post date:** [June 17, 2019, 8:58pm UTC](https://discourse.processing.org/t/looks-like-your-mixing-static-and-active-modes/12137/3 "2019-06-17T20:58:19Z")

</div>

Thank you TfGuy44! That works great! I did not understand that all code had to be in functions or not in any functions. I missed that somehow. Also thanks for the quick response. Now I understand.  
er45
