### Select statements

The Select statement is similar to an If statement. Sometimes however, you can write formulas that are clear and less repetitive using the Select statement. This example evaluates the {Customer.Fax} field to determine if the area code is for Washington state (206, 360, 509) or British Columbia, Canada (604, 250):

    Rem Select example 1
    Select Case Left ({Customer.Fax}, 3)
       Case "604", "250"
          formula = "BC"
       Case "206", "509", "360"
          formula = "WA"
    End Select

The expression right after the Select Case keywords is called the Select condition. In the above example it is Left ({Customer.Fax}[1 To 3]). The Select statement tries to find the first Case that matches the Select condition, and then executes the statements following it, up until the next Case.

    Rem Same effect as Select example 1
    Dim areaCode As String
    areaCode = Left ({Customer.Fax}, 3)
    If areaCode In Array ("604", "250") Then
       formula = "BC"
    ElseIf areaCode In Array ("206", "509", "360") Then
       formula = "WA"
    End If

##### Example

This formula groups the number of Oscar nominations a movie received into low, medium, high or extreme categories and in the process, shows some of the possibilities for the expression lists following the Case labels. Notice the optional Case Else clause. If none of the Case expression lists are matched by the preceding Case clauses, then the Case Else clause is matched. For example, in the following example, if {movie.NOM} is 11, then the formula returns "extreme".

    Rem Select example 2
    Select Case {movie.NOM}
       Case 1,2,3, Is < 1
          Rem Can have multiple statements in the
          Rem statement blocks
          formula = "low"
       Case 4 To 6, 7, 8, 9
          formula = "medium"
       Case 10
          formula = "high"
       Case Else
          formula = "extreme"
    End Select

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com