Hitachi

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


7.1.6 Select Case

Purpose

Flow control statement that executes one of a number of statement blocks, depending on the value of a conditional expression.

Syntax
Select Case TestExpression
[Case ExpressionList-n
  [Statements-n]]...
[Case Else
  [ElseStatements-n]]
End [Select]
Arguments
TestExpression

Write any conditional expression.

ExpressionList-n

Mandatory if you write a Case clause. Specify one or more expressions, delimited with commas.

Statements-n

Statements to be executed if TestExpression matches any one of ExpressionList-n. You can write multiple statements in Statements-n, with a line return after each one.

ElseStatements

Statements to be executed if TestExpression does not match any of the Case clauses. You can write multiple statements in ElseStatements, with a line return after each one.

Description

If TestExpression matches any ExpressionList in a Case clause, the statements following that Case clause are executed up to the next Case clause or up to the End Select statement. When the block has executed, control passes to the statement following End Select. If TestExpression matches more than one Case clause, only the statements following the first match are executed.

The Case Else clause specifies the ElseStatements to be executed if TestExpression does not match any ExpressionList in any of the Case clauses. Although a Case Else clause is not always required, it is a good idea to write a Case Else statement in a Select Case block to process unexpected TestExpression values. If no ExpressionList in any of the Case clause matches TestExpression and there is no Case Else statement, execution continues from the statement following End Select.

Select Case statements can be nested. Each nested Select Case statement must have a corresponding End Select statement.

Example
' Determine argument Result, create and output a message to "Result.txt".
Sub LogOutput ( Result )
  Dim MessageText
  Select Case Result
  Case "OK"
    MessageText = " End normally. " & "Status=[" & Result & "]"
  Case "NG"
    MessageText = " End abnormally. " & "Status=[" & Result & "]"
  Case Else
    MessageText = " An unexpected error occurred. " & _
                    "Status=[" & Result & "]"
  End Select
  Message ( Target_File ,_SCF_+"Result.txt" ,MessageText _
          ,128 ,1024 )
End Sub
JP1/Script version

Supported from JP1/Script 01-00.