Versions Compared

Key

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

...

Type

Description

IF-ELSE Statement

Evaluates the expression after “if“. If the expression is true, then the code immediately following “if“ will be executed. Otherwise, the contents immediately following “else“ will be executed. The user can specify multiple cases to evaluate by using the ‘else if’ expression.

WHILE/DO-WHILE Statement

Statements for loop processes.

FOR Statement

A statement for more complex loop processes.

SWITCH-CASE Statement

Statement for executing different processes based on different conditions.

GOTO Statement

A statement that forces the flow of the program to go to a specific location in the script.

CONTINUE Keyword

A keyword used in loop processes.

RETURN Keyword

A keyword that designates the value that will be returned to the caller.

RUNSCRIPT Keyword

A keyword that calls an external program.

(1) IF-ELSE Statement

The IF-ELSE statement is one of the most frequently used logical decision-making statements. It supports nested IF statements such as: If (condition 1) { If (condition 2) { … } }. There is no limit on the level of nested IF. The Else statement may be omitted. The ‘Else If’ statement is used for additional conditions following an If statement. For a given If-Else If-Else statement, only one branch will be executed. Once one condition is met, none of the following “Else If“ or “Else“ conditions are evaluated.

...

Do {

// Write the loop statement when the condition is True.

// The loop statement will be executed once at least.

} While (A<10); // mark the end of the statement with ‘ ; ’.

(3) FOR Statement

In this statement, all expressions for the initialization, the decision-making, and the post-loop process are described in a single statement line.

...

Switch (A)

{

Case 1:

// Write the program when A is 1.

Break;

Case 5:

Case 7:

// Write the program when A is 5 or 7.

Break;

Default:

// Write the default program. This section can be omitted.

Break;

}

(5) CONTINUE Keyword

The CONTINUE keyword is used in loop statements. When the system meets the CONTINUE keyword, the flow skips the remainder of the loop and moves to the first part of the current loop. This keyword is often used in the WHILE, DO-WHILE, and FOR statements. It is especially useful when there are multiple decision-making statements (IF-ELSE) in the loop.

...

While (A<10)

{

A = A +1;

If (A < 5)

{

// Process when A is less than 5

   Continue;

}

  // Process when A is greater than or equal to 5

}

(6) RETURN Keyword

Every program returns a result value to the caller. The RETURN keyword is used for designating a return value and termination of the program.

...