Bookshelf Home | Contents | Index | PDF |
Siebel eScript Language Reference > Siebel eScript Language Overview > Siebel eScript Statements > switch StatementThe switch statement makes a decision based on the value of a variable or expression. Syntaxswitch( switch_variable )
UsageThe switch statement is a way of choosing among alternatives when each choice depends upon the value of a single variable. The variable switch_variable is evaluated, and then it is compared to the values in the case statements (value1, value2, ..., default) until a match is found. The statement block following the matched case is executed until the end of the switch block is reached or until a break statement exits the switch block. If no match is found and a default statement exists, the default statement executes. Make sure to use a break statement to end each case. In the following example, if the break statement after the "I=I+2;" statement were omitted, the computer executes both "I=I+2;" and "I=I+3;", because the Siebel eScript interpreter executes commands in the switch block until it encounters a break statement. ExampleSuppose that you had a series of account numbers, each beginning with a letter that indicates the type of account. You could use a switch statement to carry out actions depending on the account type, as in the following example: switch ( key[0] ) See Also |
Siebel eScript Language Reference |