NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

9.9.2 Select statement

A Select statement executes statements based on the value of an expression.

When a Select statement is executed, the select expression is evaluated and the Case statements are evaluated in order of textual declaration. The first Case statement that evaluates to True has its block executed. If no Case statement evaluates to True and there is a Case Else statement, then that block is executed. Once a block has finished executing, execution passes to the end of the Select statement – there is no fall-through.

A Case clause may take two forms. One form is an optional Is keyword, a relational operator and an expression. If the Select expression is E, the relational operator Op and the Case expression E1, then the Case is evaluated as "E OP E1". There must be a valid operator given the types of the two expressions, else an error occurs.

The other form is an expression with an optional keyword To and an optional second expression. If the Select expression is E, the first Case expression E1 and the second Case expression E2, then the Case is evaluated either as "E = E1" (if no E2 is specified) or "(E >= E1) And (E <= E2)". The operators must be valid for the types of the two expressions, else an error occurs.

SelectStatement ::=
 Select [ Case ] Expression StatementTerminator
 [ CaseStatement+ ]
 [ CaseElseStatement ]
 End Select StatementTerminator
CaseStatement ::=
 Case CaseClauses StatementTerminator
 [ Block ]
CaseClauses ::=
 CaseClause |
 CaseClauses , CaseClause
CaseClause ::=
 [ Is ] RelationalOperator Expression |
 Expression [ To Expression ]
CaseElseStatement ::=
 Case Else StatementTerminator
 [ Block ]