Shop OBEX P1 Docs P2 Docs Learn Events
PBASIC 2.5 and labels — Parallax Forums

PBASIC 2.5 and labels

DonDon Posts: 34
edited 2004-08-07 23:26 in BASIC Stamp
I downloaded the short document the PBasic 2.5 features.· I was a bit puzzled by the discussion of labels requiring a colon.· I thought that labels have always required a colon.· It this not true?· If not, in what circumstances would you want to use a label without a colon?

Perhaps not requiring a colon on labels was an oversight/bug in versions prior to 2.5.

·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-07 19:42
    Indeed, earlier versions of the compiler tolerated labels without colons. Enforcement was added to promote clean coding.

    Colons can also be used as a separater for multi-line statements, like this:

    · DO : LOOP UNTIL (ResetBtn = Pressed)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • DonDon Posts: 34
    edited 2004-08-07 20:37
    Thanks.

    In your example of multi-line statements, is it required to have a space after the DO to prevent the compiler from interpreting it as a label. I assume that if this is the case, it would then complain about using a reserved word as a label.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-07 23:26
    No, the space (recommended) is a matter of my style. Since the colon can be used as a legal separater, the compiler will not complain if you don't use the spaces that I choose to put in my code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.