Shop OBEX P1 Docs P2 Docs Learn Events
undeclared label error — Parallax Forums

undeclared label error

CarStaCarSta Posts: 16
edited 2008-05-08 21:25 in General Discussion
I am trying to use a label as an escape from a break statement. It is telling
me that it is undeclared label error. How do I declare a label??

Thanks,

Carey

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-05-08 09:07
    From Javelin manual page 96:

    The break statement, if executed, immediately terminates the loop.· The continue statement, just moves on
    to the next iteration of the loop (in this case, that prevents even numbers from getting to the bottom of the loop).

    Unlike C, Java allows you to include a label as the target of a break or continue.· This lets you terminate or
    continue nested loops.· For example:

    Loop0:
    · for (x=1;x<10;x++) {
    ··· for (y=1;y<20;y++) {
    ····· .
    ····· .
    ····· .
    ····· if (checkexit()==true) break Loop0;
    ··· }
    · }

    Also see page 115/116.

    regards peter
  • CarStaCarSta Posts: 16
    edited 2008-05-08 21:25
    Thanks Peter,

    I took your code and as written it runs fine. When I tried to insert the label below the break code, that is when
    I got the undeclared label error. It has to be aware of the label before using it. Wish they had mentioned that in
    the manual.

    Again Thanks,

    Carey
Sign In or Register to comment.