Takes a variable number of conditional statements to compare against a single source
Description:
Traditional Select / Case / End Select
conditional block(s) to assist with flow control of a procedure using a single source comparison.
These conditions in an If / End If
block can take two forms:
If Field/Expression
(Boolean)If Field/Value Condition Field/Value/Expression
(Condition)When Boolean, no value is specified on the Select line. Each Case line then must be:
( )
to be evaluatedNot
operator can be placed in front of a boolean test to reverse the boolean logic. In the case of an Expression, Not
must come before the ( ) eg. Case Not ( )
When Condition:
( )
must not be usedCase Else:
Case Else
statement may be included at the end of a Select / End Select block, and will execute when all previous Case
tests are FalseNotes:
Select / End Select
blocks are not allowed, but inline If / Then
tests are allowed within them, and If / End If
blocks may be used inside a Select / End Select block and vice versa. This decision was made early on to prevent "spaghetti code", forcing developers to write more modular code by wrapping these nested levels in Methods, and it has worked well.Examples:
Method Start(pQ)
[Pull] (pQ), "Ajax Route Action"
Select
Case Ajax : AjaxReply : Start.Ajax pQ
Case Route : Start.Route pQ
Case Action : Start.Action pQ
Case Else : Default.Get pQ
End Select
End Method
Method Start.Route(pQ)
[Pull] (pQ), "Route"
Select Route
Case cRouteFirst : Route.First pQ
Case cRouteSecond : Route.Second pQ
Case Else : End.NotFound pQ
End Select
End Method
[New] SixtyFive = 65
Select SixtyFive == 'Test against a number
Case 55
abc = 123
Case 65
def = 456
End Select
[New] SixtyFive = 65
Select SixtyFive
Case > 7
HtmlAlert "Does not display because this is the text comparison operator"
Case >> 7
HtmlAlert "This is true because this is the numerical comparison operator"
End Select
If Req.Mode = "Post" : And Req.HasFile
Or Req.Mode = "Get" : And Not Req.HasFile
abc = 123
Else
Select
Case Not (SessionIsGroupType$ "DB Admin, Office Admin, Office")
HtmlAlert "When evaluating an expression, surround it with ( )"
abc = 321
Case 456 == (abc - def)
HtmlAlert "When testing Math, use the doubled-up Math operators"
zxy = 456
Case bOther
def = 654
If bFinal Then Other.Method.DoSomething
Case Else
def = 456
End Select
End If