6.2.5 Branch and Repetition


In the program, the flow of control can be changed using GOTO and IF statement, which contains three branches and repeated operations:



GOTO statement (unconditional branch)

Branch and repeat:

IF statement (conditional branch: if... then...)


WHILE statement (when ... repeat)


1. Unconditional branch (GOTO Statement)


Jumps to the branch with sequence number n. When the sequence number greater than 1 to 99999 is specified, an alert message will pop up. In addition, the serial number can also be specified by an equation.

GOTO n ;n is a serial number from 1 to 99999


Example:

GOTO1;

GOTO#10;


2. Conditional branch (IF Statement)


Specify a statement after IF.


  • IF [<statement>] GOTOn

When the given statement expression is satisfied, it jumps to the branch with the serial number n; if the statement expression is not satisfied, the next stroke expression is executed.


IF[<statement>]GOTOn


  • IF [<statement>] THEN

When a given statement expression is satisfied, a macro program line that was previously given is executed and only a single macro program line is executed.


If the values ​​of variables #1 and #2 are the same, the value of variable #3 will be set to 0。

IF [#1 EQ #2] THEN#3=0;


  • Explain

Statement

In the statement expression, there must be an operator between the two variables or between the variable and the constant, and the statement expression must be written in square brackets ([ ]). Besides the variable, the expression can also be used.


Operator

The operator consists of two English letters and is used to compare the size of the two values.


Operator

Function

EQ

Equal (=)

NE

Not equal (≠)

GT

Greater than (>)

GE

Greater than or equal to (3)

LT

Less than (<)

LE

Less than or equal to (′Γ)


3. Repetition (WHILE Statement)


When the given condition is satisfied, the program beginning with DO begins with END. If the given condition is not satisfied, execution will continue from the program line after END.


Repetition (WHILE Statement)


  • Explain

When the given condition is satisfied, a program that start with "DO" and end by "END" after "WHILE" is executed. If the given condition is not satisfied, execution will continue from the program line after "END". Its format is the same as the "IF" statement formula. The numbers following "DO" and "END" are the execution range identifiers, which can be 1, 2, or 3. If other numbers are used, a warning message will pop up.


  • Multi-level execution

IDs (1~3) in the DO-END loop can be used multiple times, but please note that if the program contains interlaced repeat loops (DO range overlaps), the system will pop out of the alert message.


Multi-level execution