In VB.net they use the AndAlso and the OrElse (Think these are the syntax
names) to indicate a conditional should use short circut operations.
If they exist in VBS I would guess they perform the same, if not then likely
VBS does not support it but this is just a guess.
Rick USA
----- Original Message -----
From: "David Helkenn" <[email protected]>
To: <[email protected]>
Cc: <[email protected]>
Sent: Monday, March 26, 2012 5:11 PM
Subject: ShortCircuit logical operators
Hello,
I am curious to learn if VBS has any support for short-circuit operators,
as in some higher level languages? The VBS reference is silent on this
point. For example, the expression:
if (A and B) or (C and D) then
...
end if
can be 'short-circuit' to the then portion if A is true -- *WITHOUT*
evaluating B, C, or D. This can come in very handy if verifying something
is in range of an array index *BEFORE* evaluating B, C, or D which may
depend upon a valid index variable. You can also see that if this
expression must be split apart into their own if statements, the code can
become very complicated, duplicated, and error prone in a hurry. If I have
to break it apart, I think I'd opt for boolean functions (more than one
would be needed) to use in the expression. but, shortCircuit operators are
a lot more convenient.
Thanks!
David Helkenn