Takes a variable number of conditional statements
Description:
Traditional If / End If
conditional block(s) to assist with flow control of a procedure.
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:
( )
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. If Not ( )
When Condition:
( )
must not be usedAnd / Or / ElseIf / Else:
And
statement will add additional criteria to a test. There may be as many And
statements as neededOr
statement will add an alternative test. There may be as many Or
statements as neededAnd
and Or
statements can be thought of logically as (W And X) Or (Y And Z)
-- It is not valid to organize as (W Or X) And (Y Or Z)
And
and Or
are statements, they must be on their own logical lines of code. Use the :
operator to start a new logical line of code on the same line of textElseIf
statement specifies an additional test for when the If
statement and any preceding ElseIf
statements evaluated to False. There may be as many ElseIf
statements as neededElse
statement may be included at the end of an If / End If block, and will execute when the If
test and all/any ElseIf
tests are FalseNotes:
Then
may not be used at the end of these statements, since an If / Then
pair is used on a single line with a single trailing commandIf / End If
blocks are not allowed, but inline If / Then
tests are allowed within them, and Select / End Select
blocks may be used inside an If / End If 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:
If Req.Mode = "Post"
abc = 123
def = 456
End If
If Req.Mode = "Post" : And Req.HasFile
Or Req.Mode = "Get" : And Not Req.HasFile
abc = 123
ElseIf Not (SessionIsGroupType$ "DB Admin, Office Admin, Office")
abc = 321
ElseIf 456 == (abc - def)
HtmlAlert "When testing Math, use the doubled-up Math operators"
zxy = 456
ElseIf bOther
def = 654
If bFinal Then Other.Method.DoSomething
Else
def = 456
End If
If (SessionIsGroupType$ "DB Admin, Office Admin, Office")
HtmlAlert "When evaluating an expression, surround it with ( )"
End If
If 65 >> 7
HtmlAlert "This is true because this is the numerical comparison operator"
End If
If 65 > 7
HtmlAlert "Does not display because this is the text comparison operator"
End If
[New] True = "y"
[New] False = ""
If True : HtmlAlert "This is true" : End If
If False
HtmlAlert "Does not display"
End If
If True : And True
HtmlAlert "This is true"
End If
If False : And False
HtmlAlert "Does not display"
End If
If True : And True : And False
HtmlAlert "Does not display"
End If
If True : Or True
HtmlAlert "This is true"
End If
If True : Or False
HtmlAlert "This is true"
End If
If True : And True
Or False
HtmlAlert "This is true"
End If
If True
Or False : And True
HtmlAlert "This is true"
End If
If True
Or False : And False
HtmlAlert "This is true"
End If
If False
Or False : And True
HtmlAlert "Does not display"
End If
If True : And False
Or True : And True
HtmlAlert "This is true"
End If
If False : Or False : Or False : Or True : Or False : Or False
HtmlAlert "This is true"
End If