IF..THEN can operate in 2 manners. In one form, the THEN in an IF..THEN is essentially a GOTO. If the condition is true, the program will GOTO the label after the THEN. If the condition evaluates to false, the program will continue at the next line after the IF..THEN. Another statement may not be placed after the THEN, it must be a label.
If Pin0 = 0 Then pushd ' If button connected to Pin0 is pushed (0), jump to label pushd
If B0 >= 40 Then old ' If the value in variable B0 is greater than or equal to 40, jump to old
If PORTB.0 Then itson ' If PORTB, pin 0 is high (1), jump to itson
If (B0 = 10) AND (B1 = 20) Then loop
In the second form, IF..THEN can conditionally execute a group of Statements following the THEN. The Statements must be followed by an ELSE or ENDIF to complete the structure.
If B0 <> 10 Then
B0 = B0 + 1
B1 = B1 - 1
Endif
If B0 = 20 Then
led = 1
Else
led = 0
Endif
Bookmarks