Shop OBEX P1 Docs P2 Docs Learn Events
If then — Parallax Forums

If then

NeoneuronNeoneuron Posts: 9
edited 2009-04-19 17:02 in BASIC Stamp
Hello again!

I tried to make this program work. It is from the What is a Microcontroller PDF that we have here on the Parallax Website, pages 81-82. It keeps stopping at THEN. The error says: 'Expected a Label'

Thanks for any Help!!

' {$STAMP BS2}
' ($PBASIC 2.5}

DO

DEBUG ? IN3

IF (IN3 - 1) THEN

HIGH 14
PAUSE 50
LOW 14
PAUSE 50

ELSE
PAUSE 100

ENDIF

LOOP

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-19 16:59
    You mistyped the $PBASIC statement. Notice that you have an open parenthesis ( at the beginning when what you need is an open brace {

    The $PBASIC statement is being treated as an ordinary comment and the compiler is using the 2.0 version of the PBASIC syntax.
    The 2.0 version requires a label after the THEN. The 2.5 version allows DO / LOOP and IF / ELSE / ENDIF. Version 2.0 is the default.
  • JeanDJeanD Posts: 15
    edited 2009-04-19 17:00
    With the PBasic, "IF THEN" is a bit special. Well at least that was my experience with a BS2 chip.
    You can't just throw instructions after a THEN.
    In fact THEN calls a sub-program.

    For instance :

    IF x = 3 THEN subname

    subname :

    INSTRUCTIONS
  • NeoneuronNeoneuron Posts: 9
    edited 2009-04-19 17:02
    Thanks again Mike!!
Sign In or Register to comment.