Ask for help for the "expecting EOF, found 'for"

Dear ALL: I just type the following simple code, and shown the error message of

“expecting EOF, found 'for”

can some one give me the guidence of this problem, thanks a lot


void setup(){
  size(200, 200);
  noStroke();
  background(255);
  fill(0, 102, 153, 204);
  smooth();  noLoop();
}

void draw(){
  circles(40, 80);
  circles(90, 70);
}

void circles(int x, int y) {
  ellipse(x, y, 50, 50);
  ellipse(x+20, y+20, 60, 60);
}


for (int i = 0; i < 80; i = i+5) {
  line(30, i, 80, i);
}
1 Like

{ } is to group code
and the PDE editor helps you to find the begin and end !
position your cursor behind a { and you see the corresponding } as [ } ]


also to see the code structure better use the
[ctrl][t] autoformat


and to post the code here at the forum
use the
</> Preformatted text button of the forum editor header menu


your last for loop is not inside any function, and that confuses the ?precompiler?

in that version you see something

void setup() {
  size(200, 200);
  //noStroke();
  background(255);
  fill(0, 102, 153, 204);
  smooth(); 
  noLoop();
}

void draw() {
  circles(40, 80);
  circles(90, 70);
  lines();
}

void circles(int x, int y) {
  ellipse(x, y, 50, 50);
  ellipse(x+20, y+20, 60, 60);
}

void lines() {
  for (int i = 0; i < 80; i = i+5) {
    line(30, i, 80, i);
  }
}

possibly not what you wanted but now you can start from here.

1 Like