|IF ... THEN ... ELSE ... ENDIF|
IF Condition THEN
Evaluate Condition and, if it is true, run the code block that follows THEN, otherwise jump to the (optional) code block that follows ELSE. If no ELSE block is provided, the program will continue at the line that follows ENDIF.
IF...THEN...ELSE is a primary decision maker that allows one block of code or [optionally] another to run based on the result (True or False) of a condition. The available comparison operators are:
|>=||Greater Than or Equal To|
|<=||Less Than or Equal To|
Comparisons are always written in the form: Variable Op Value.
This simple example shows how IF...THEN...ELSE is used with a subroutine that can accept a byte or word parameter.
' Use: DELAY ms ' -- 'ms' is delay in milliseconds, 1 - 65535 DELAY: IF __PARAMCNT = 1 THEN tmpW1 = __PARAM1 ' save byte value ELSE tmpW1 = __WPARAM12 ' save word value ENDIF PAUSE tmpW1 RETURN
Related instruction: IF ... THEN