Shop OBEX P1 Docs P2 Docs Learn Events
Error: "Expected a Label" - bs2 from the 'whats a microcontroller' kit — Parallax Forums

Error: "Expected a Label" - bs2 from the 'whats a microcontroller' kit

Hi folks,

Noobie here :) I recently picked up parallax's 'whats a microcontroller' book/kit and am having a lot of fun learning how to program these controllers. I am working with the "readpushbuttonstate.bs2" program. When i run the program, i get "error 148:Expected a label" after the THEN statement. Below is my code and my pc specs.
Win 7 64bit
Basic Stamp 2.5.3
USB connection
'{PBASIC 2.5}
'{$STAMP BS2}

DO
  DEBUG ? IN3

    IF (IN3 = 1) THEN
      HIGH 14
      PAUSE 50
      LOW 14
      PAUSE 50

    ELSE
      PAUSE 100

  ENDIF

LOOP

Any thoughts on what i should be modifying? It looks identical to what is in the book (page 72).

Thank you for your help! :)

Comments

  • SapphireSapphire Posts: 496
    edited 2015-10-23 15:57
    You need a $ character before PBASIC in the top line.

    Instead of typing these in, you can click an icon in the toolbar which will insert them correctly.

    Edit: corrected first line.
  • Kris1 wrote: »
    When i run the program, i get "error 148:Expected a label" after the THEN statement.

    Kris1,

    That error is indicative of having the {$PBASIC 2.0} directive instead of {$PBASIC 2.5}.

    PBASIC 2.0 only supports a THEN to a label, where 2.5 supports a THEN to an action.

    I don't have a Stamp here at work to verify what Sapphire said, but the toekenization of the directives with/without a space between the single quote and the left brace made no difference.
  • You've got "'{PBASIC 2.5}" as the first line of your program. It should be "'{$PBASIC 2.5}".
  • When you click the icon, (see the BASIC Reference Manual beginning on page 43), it puts in exactly what it wants to see.
  • Thanks, guys. The space and $PBASIC did the trick! :)
Sign In or Register to comment.