-
Pic Basic help
OK, this is probably really simple but I can't seem to make it work. I'm using a IF THEN statement like this: IF (variable) = (a number) THEN (Label)
Label: some code
END IF
When I try to compile, the error message I get is END IF without a matching IF---THEN
Basically, what I am trying to do is jump out of a loop to "Label" if the variable is a specific number.
Reading the PICBASIC compiler manual, I can't see what I'm doing wrong. Thanks for any help.
Klaus
-
Code:
Start:
IF MyVar=9 THEN
LCDOUT $FE,1,"How's Santa today?"
ELSE
GOSUB PassGoAndClaim200Bucks
ENDIF
IF MyVar=8 THEN
PAUSE 500
LCDOUT $FE,1,"Doh!"
STOP
ENDIF
IF MyVar=7 THEN WhoLetTheDogsOut
GOTO Start
'
'
'
PassGoAndClaim200Bucks:
'
' Plah Plah Plah
'
RETURN
'
'
'
WhoLetTheDogsOut:
'
' Woo... Woo... Woo
'
GOTO Start
Make sure you didn't forgot a ENDIF somewhere in your code while editing it... yeah it happen ;)
-
Hi Klaus,
When you have a one-line IF statement you don't use EndIf. So simply:
Code:
If A = B Then myLabel
should do it.
/Henrik.
-
Thanks very much. Leaving out the ENDIF worked.