Datasheet
Programming PIC Microcontrollers in BASIC - mikroElektronika
condition. The BASIC instruction of branching in BASIC language is the IF instruction, with several 
variations that provide the necessary flexibility.
4.1.1 IF..THEN Statement – conditional program branching
Syntax
if expression then
 statements1
[ else
 statements2 ]
end if
Description Instruction selects one of two possible program paths. Instruction IF..THEN is the 
fundamental instruction of program branching in PIC BASIC and it can be used in 
several ways to allow flexibility necessary for realization of decision making logic.
Expression returns a True or False value. If expression is True, then statements1 
are executed; otherwise statements2 are executed, if the else clause is present. 
Statements1 and statements2 can be statements of any type.
Example The simplest form of the instruction is shown in the figure below. Our example 
tests the button connected to RB0 - when the button is pressed, program jumps to 
the label "Add" where value of variable "w" is increased. If the button is not 
pressed, program jumps back to the label "Main".
dim j as byte
Main:
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/04.htm (2 sur 9)05/11/2004 02:15:36










