Error Message on PBASIC 2.5
James Anderson
Posts: 52
on a program i wrote in PBASIC 2.5 , i get an error message saying "ELSEIF must be preceded by IF" when I clearly typed IF.
could someone please explain this to Me?
thanks,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There once was a lady named Bright
who traveled much faster than light
She departed one day in a relative way
and Returned on the Previous Night
Cheers,
Wannabe Ub3r Geek
World of Warcraft
Star Trek official website
Google (Man's best friend...)
could someone please explain this to Me?
thanks,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There once was a lady named Bright
who traveled much faster than light
She departed one day in a relative way
and Returned on the Previous Night
Cheers,
Wannabe Ub3r Geek
World of Warcraft
Star Trek official website
Google (Man's best friend...)
bs2
1013B
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There once was a lady named Bright
who traveled much faster than light
She departed one day in a relative way
and Returned on the Previous Night
Cheers,
Wannabe Ub3r Geek
World of Warcraft
Star Trek official website
Google (Man's best friend...)
Post Edited (wannabe uber-geek) : 7/17/2006 1:38:23 AM GMT
This seems to work okay:
IF pulse5 < 1500 THEN
SEROUT lcd , lcdbaud , [noparse][[/noparse]18] 'check ch5 turn off backlight if switch off
ELSEIF pulse5 > 1500 THEN
SEROUT lcd , lcdbaud ,[noparse][[/noparse]17] 'vice versa
ELSE
SEROUT lcd , lcdbaud , [noparse][[/noparse]"error!"]
ENDIF
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Pbasic originally had
IF (condition) THEN (Statements or Label)
all on the same line, and you can still write code that way. (it's the only way on a Stamp1)
The interpreter Knows the IF statement is done at the end of the line.
But, when you use the expanded ELSEIF, ELSE, ENDIF construct, you need to put the-- (Statements or Label) -- part on the following line to tell the interpreter you are following the new construct.
You code needs to look like this:
IF (condition) THEN
(Statements or Label)
ELSEIF (condition) THEN
(Statements or Label)
ELSE
(Statements or Label)
Endif
If THEN is the last thing on the line, the interpreter knows the IF construct isn't over yet.
You are getting the error because the interpreter thinks you wrote code the old way and the original IF statement is finished.
It is looking for the IF statement for the new method in the code that follows.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There once was a lady named Bright
who traveled much faster than light
She departed one day in a relative way
and Returned on the Previous Night
Cheers,
Wannabe Ub3r Geek
World of Warcraft
Star Trek official website
Google (Man's best friend...)