PDA

View Full Version : Pic Basic help



Klaus
- 20th April 2008, 18:20
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

mister_e
- 20th April 2008, 18:25
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 ;)

HenrikOlsson
- 20th April 2008, 18:31
Hi Klaus,
When you have a one-line IF statement you don't use EndIf. So simply:
If A = B Then myLabel should do it.

/Henrik.

Klaus
- 20th April 2008, 19:01
Thanks very much. Leaving out the ENDIF worked.