IF ELS and Labels
earthlingzed
Posts: 14
I am a newby getting myself acqquainted with the BS2, but I ahve a bit of programming expereince.
I am trying to create a simple if else statement and I keep getting error 148 asking for a label.
What is a label? It is not something I have run across in any other programming language.
Here is what I am trying to do:
I am trying to create a simple if else statement and I keep getting error 148 asking for a label.
What is a label? It is not something I have run across in any other programming language.
Here is what I am trying to do:
' {$STAMP BS2} ' {$PBASIC 2.0} INPUT 6 OUTPUT 7 Main: LOW 7 IF (IN6 = 1) THEN HIGH 7 Else LOW 7 END GOTO main
Comments
The exception to this is if you write:
if in0 =0 then high 5
With a one-line command you do not need the endif.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester?
http://hometown.aol.com/newzed/index.html
·
Second: PBASIC 2.5 lets you define an IO pin as a PIN, and can simplify syntax.· Thus, your example becomes:
The key is that the compiler knows that your pins are pins and coverts
Led = Ctrl
to:
OUT7 = IN6
You next logical question is: What if I want to change to an active-low input?· No problem· Change the line to:
Led = ~Ctrl
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Many thanks!