token problem

Hey everyone, I'm desperately trying to fix this "unexpected token: void" problem, but I just can't help it. I'm new to Processing and probably the solution is obvious.. The error occurs in the last method. Maybe you could give me a hint ..

void draw() {

  int passedTime = millis() - savedTime;

  if(passedTime > totalTime) {
  return;
  }

    void checkout() {
    for(Object o : ArrayField) {
    if(o.next().getObject instanceof Key) {
      return;
    }
    }
    }


}
Tagged:

Answers

  • Looks like you've got to functions, draw() and checkout(), but you're defining checkout() inside draw()! Maybe you should try moving the } on line 18 to line 8?

  • edited May 2014

    yes

    when you press ctrl-t the code gets auto-format

    then you would see it

    it's just that { and } must always match in pairs

    { and }

    {{ and }} etc.

  • edited May 2014

    Okay, I put the checkout() outside of draw, and draw is closed properly now. Nevertheless I get the same error, even though every method is closed.. It seems to me that there's something wrong inside checkout(), still got any ideas?

    void checkout() {
      for (i = 0; i < keyFelder; i++) {
        if ([i+1] instanceof Key) {
          return;
        }
      }
    }
    

    *Edit: it's not the same error, now it's just "Unexpected token: [ " *Edit 2: Ok sorry, got it fixed, I just realized I forgot to call the array inside the if.

  • Great, you got it. I'm glad.

    ;-)

Sign In or Register to comment.