Hitachi

JP1 Version 11 JP1/Script Description and Reference (For Windows Systems)


7.1.5 If...Then...Else

Purpose

Flow control statement that executes conditional processing dependent on the value of an expression.

Syntax 1
If Condition Then
   [Statements]
[Else
   [ElseStatements]]
End [If]
Syntax 2
If Condition Then
  [Statements]
[ElseIf Condition-n Then
  [ElseifStatements]]...
[Else
  [ElseStatements]]
End [If]
Arguments
Condition

Conditional expression that evaluates to true or false.

Statements

Statements to be executed if Condition is true. You can write multiple statements in Statements, with a line return after each one.

Condition-n

Same as the Condition argument.

ElseifStatements

Specify a group of statements to be executed if Condition-n is true. You can write multiple statements in ElseifStatements, with a line return after each one.

ElseStatements

Specify a group of statements to be executed if none of the conditions (Condition or Condition-n) defined before Else is true. You can write multiple statements in ElseStatements, with a line return after each one.

Description

The Condition in the If...Then...Else statement is evaluated first. If Condition is true, the statements following Then are executed. If Condition is false, the Else clause (if any) is executed in the first syntax. In the second syntax, the conditions (Condition-n) specified in the ElseIf clauses are evaluated. If any of these conditions is true, the statements following the associated Then are executed. If all of the ElseIf conditional expressions are false (or if there are no ElseIf clauses), the statements following Else are executed. After executing the statements following Then or Else, program execution continues from the statement following End.

You can define Else and ElseIf clauses as required. In the second syntax, you can specify as many ElseIf clauses as you wish in the If block, but no ElseIf clauses are allowed after the Else clause. You can also place If statements in a nested structure.

JP1/Script version

Supported from JP1/Script 01-00.