Versions Compared

Key

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

...

Type

Description

IF-ELSE Statement

One of the most frequently used logical decision-making statementsEvaluates 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.

WHILE/DO-WHILE Statement

Statements for the loop processprocesses.

FOR Statement

More complex but useful for A statement for more complex loop processes.

SWITCH-CASE Statement

Statement for the executing different processes according to the several casesbased 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 the loop processprocesses.

RETURN Keyword

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

RUNSCRIPT Keyword

A keyword that calls the 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-ELSE IF-ELSE IF…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.

If (A == 1)

{

    // A program for when A is 1

}

Else If (A == 2)

{

    // A program for when A is 2

}

Else

{

    // A program for when A is not neither 1 nor 2

}

 (2) WHILE/DO-WHILE Statement

The WHILE/DO-WHILE is a statement for a loop process. The statements below the while WHILE keyword will be repeated as long as the condition followed by the WHILE keyword is True.

...

The subordinate statements may will never be executed if the conditions for the WHILE statement are not true. If you use a DO-WHILE statementsstatement, you can execute the loop statement will be executed at least once. Then After the first execution, the system will check the condition within the WHILE statement.

...

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

...

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

FOR (Initialization statement; Decision-Making statement; Post-Processing statement)

In the example above, the loop statement will be executed 10 times. On the first execution, A will have a value of 0. After this, the statement “A=A+1“ will execute, and the loop will run again. The loop will continue to run until A is equal to 10 or greater.

(4) SWITCH-CASE Statement

This statement is used when the different processes are needed within the for different cases. Each case can be distinguished by the an unlimited number of CASE statements.

...

The DEFAULT statement does not need a constant. This statement is executed if none of the other cases are to be executed. The DEFAULT statement can be omitted if needlessit is not needed.

The BREAK keyword plays the role of terminating the SWITCH statement. If there is no BREAK keyword in the process of the program, the after a CASE statement, then corresponding CASE/DEFAULT statement statements will also be executed. This means that multiple CASEs can execute the same result, as shown in the example below.

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;

}

...

The GOTO statement controls the flow of the program directly. This statement uses an index (unique name starting with “@”) to point out to the new location.

The index name must not be duplicated with variables, tags, or program names.

VAR A; 

A = 0;

@ComeHere            // Assign an index.

If (A < 10)

{

    A = A + 1

    Goto ComeHere;   // Move to the assigned index.

}

...

The CONTINUE keyword is used in the loop statementstatements. 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.

...

The program MyPgm will be called in the other another program as shown below. Then the variable ‘RtnValue’ will receive the value ‘6’.

...

When you call an external program directly, the caller will be in stand-by standby mode until the called program (the external program) ends its operation.

However, if you use the RunScript keyword to call an external program, the caller will not wait until the end of the called program. Both the caller and called program will be executed in parallel.

...