Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The following table is a set of statements and keywords that can be used in the script.

Type

Description

ifelse Statement

The if statement executes the instruction code when the condition is true. Otherwise, the else statement will execute its instruction code. if...else statements can be nested inside another if...else statement using the else if statement which creates a nested loop. Please note, there is no limitation on how many else if can be nested inside if...else statement.

while Statement

The while statement execution will continue until the expression becomes false.

dowhile Statement

The do statement is executed at least once before while condition is evaluated. The loop will repeat until while condition becomes false.

for Statement

A for loop repeats until a specified condition becomes false. Below is the standard syntax used by a for loop:

Code Block
languagejs
for ([initialExpression]; condition[conditionExpression]; updateExpression[incrementExpression]) {
    // instruction code
}

switchcase Statement

Executing different processes based on different conditions.

continue Statement

Terminates execution of the current iteration in a loop and then execute the next iteration in a loop.

break Statement

Terminates the execution of a loop entirely.

return Function

Ends function execution and the function caller will return specifies a value.

runScript() Function

runScript() is used to call another script program. For example, if runScript() is being used in script name "A" to call a script name "B", as soon as script A executes, script B will execute as well.

Example for ifelse:

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.

Code Block
languagejs
A = 1;
if (A == 1) {
    A = 5;
} else if (A == 2) {
    A = 10;
} else {
    A = 0;
}

Example forwhile:

In this example, 0 is set as the initial value for variable A. When A is less than 10, A will increment by 1 every execution until A equals 10. Once A equals 10, the while loop will end.

Code Block
languagejs
A = 0;
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 be executed and increment A by 1 every execution until equal to 10. Once A equals 10, the do...while loop will end.

Code Block
languagejs
A = 0;
do {
    A = A + 1;
} while (A < 10);

Example for for

In this example, In this statement, all expressions for the initialization, the decision-making, and the post-loop process are described in a single statement line.The following example displays the WHILE statement example shown above but uses the FOR statement insteadthe initial expression is 1. When i is less than 11, i will increment by 1 every execution until i equals 11. Once i equals 11, the for loop will end.

Code Block
languagejs
for (i = 1; i < 11; i = i + 1) {
    A = i;
}

For (A=0; A<10; A=A+1)

{

// Write the loop statement.

}

The FOR statement is followed by the initialization statement, the decision-making statement, and the post-processing statement.

...