The following table is a set of statements and keywords that can be used in the script.
Type | Description |
| The |
| The |
| The |
| A |
| Executing different processes based on different conditions. |
| Terminates execution of the current iteration in a loop and then execute the next iteration in a loop. |
| Terminates the execution of a loop entirely. |
| Ends function execution and the function caller will return specifies a value to be returned to the function caller. |
|
|
Example for if
…else
:
In this example, if A
equals 1, assign 5 to A
. If A
equals 2, assign 10 to A
. If A
does not equal 1 or 2, assign 0 to A
.
A = 1;
if (A == 1) {
//run this instruction if A is equal to 1.A = 5;
}
else if (A == 2) {
//run this instruction if A is equal to 2.A = 10;
}
else {
//run this instruction if A does not equal 1 or 2.A = 0;
}
Example forwhile
:
In this example, 0 is set as the initial value for variable A
. While When A
is less than 10, continue to add 1 to A
until A
is equal to A
will increment by 1 every execution until A
equals 10. Once A
is equal to equals 10, the while
loop will end.
...
while (A < 10) {
A = A + 1;
}
Example for do
...while
:
In this example, 0 is set as the initial value for variable A
. The do
statement will first get be executed and will continue to add 1 to A
until A
is increment A
by 1 every execution until equal to 10. Once A
is equal to equals 10, the do
...while
loop will end.
A = 0;
do {
A = A + 1;
} while (A < 10);
(3) FOR Statement
...