|
IT SOLUTIONS
Your full service technology partner!
|
|
![]() ![]() |
|
Languages FocusLogical operators perform conditional and, or, and not operations. Some languages support both binary logical operators that link two and unary logical operators negate (make opposite) the truth value of its argument. Finally, some languages short circuit logic. For example, with this or that, if this is an expression returning true, then that is never executed.
Intermediate1 Intermediate Level Question More Info![]()
|
ASP Classic: and, or, notSame as VB. ASP Classic logical operators:
ASP Classic never short circuits. Given the expression this or that as well as this and that, if this evaluates to false, then that is still executed.
ASP Classic Short Circuting Example:In the following example, if ASP Classic supported short circuting, the That function would never execute. It's interesting to note that VB.Net has introduced two new operators to support short cicuiting: AndAlso and OrElse for use when you code in ASP.Net. <%@LANGUAGE='VbScript'%> <html> <body> Function That() 'Notice both the This and That functions execute </html>
|
1 Intermediate Level Question
![]() |
ASP Classic Logical Operators (and, or, not) |
Same as C++ and Java. C# logical operators:
& | and, as in this and that | No Short Circuit |
&& | and, as in this and that | short circuits |
| | or, as in this or that | No Short Circuit |
|| | or, as in this or that | short circuits |
! | Not, as in Not This | |
^ | either or, as in this or that but not both |
Syntax Example:
//Given expressions a, b, c, and d: if !((a && b) && (c || d)) { //Do something. } More Info![]() |
C++ logical operators:
&& | and, as in this and that |
|| | or, as in this or that |
! | Not, as in Not This |
^ | either or, as in this or that but not both |
Syntax Example:
//Given expressions a, b, c, and d: if !((a && b) && (c || d)) { //Do something. } More Info![]() |
Same as C++ and Java. C# logical operators:
& | and, as in this and that | No Short Circuit |
&& | and, as in this and that | short circuits |
| | or, as in this or that | No Short Circuit |
|| | or, as in this or that | short circuits |
! | Not, as in Not This | |
^ | either or, as in this or that but not both |
Syntax Example:
//Given expressions a, b, c, and d: if !((a && b) && (c || d)) { //Do something. } More Info![]() |
ObjectPAL logical operators:
and | and, as in this and that |
or | or, as in this or that |
Not | Not, as in Not This |
Like VBA, ObjectPAL never short circuits. Given the expression this or that as well as this and that, if this evaluates to false, then that is still executed.
Syntax Example:;Given expressions a, b, c, and d: if Not (a and b) and (c or d) then ;Do something. endIf |
The following code snippet allows you to test out ObjectPAL's short circuiting. In the if statement of the pushButton event, the That() custom procedure executes even if This() is False.
To use the code, alter a pushButton event of a button as follows:
;This custom procedure.
proc This() Logical
msgInfo("", "This")
return False
endProc
;That custom procedure.
proc That() Logical
msgInfo("", "That")
return True
endProc
method pushButton(var eventInfo Event)
;Object always short circuits.
;The That() custom procedure executes even
;though This() returns false.
if This() and That() then
msgInfo("", "both are true")
endIf
endMethod
You can use the not operator in many contexts. One of my favorite uses for it is to toggle boolean properities with a single line of code:
BooleanProperty = Not BooleanProperty
The following demo works in all versions of Paradox for Windows. The demo uses the not operator to toggle the visible property of a box from a button.
The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.
1 Beginner Level Question
![]() |
ObjectPAL Logical Operators |
Delphi logical operators:
and | and, as in this and that |
or | or, as in this or that |
not | Not, as in Not This |
xor | either or, as in this or that but not both |
The Delphi compiler default is to short circuit multi argument boolean expressions when the result is known before the evaluation completes. To disable short circuiting, use the {$B+} compiler directive. To reset it back to the compiler default of short circuting, use the {$B-} compiler directive.
Syntax Example://Given expressions a, b, c, and d: if Not (a and b) and (c or d) then //Do something. |
You can use the not operator in many contexts. One of my favorite uses for it is to toggle boolean properities with a single line of code:
BooleanProperty = Not BooleanProperty;
For example, if you have an Image control on a form you can toggle it's visibility with a single line of code:
Image1.Visible := Not Image1.Visible;
The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.
1 Beginner Level Question
![]() |
Delphi Logical Operators |
Prism logical operators:
and | and, as in this and that |
or | or, as in this or that |
not | Not, as in Not This |
xor | either or, as in this or that but not both |
Syntax Example:
//Given expressions a, b, c, and d: if Not (a and b) and (c or d) then //Do something.
|
Java logical operators:
&& | and, as in this and that |
|| | or, as in this or that |
! | Not, as in Not This |
& | boolean logical OR (not short circuited) |
| | boolean logical OR (not short circuited) |
?: | Ternary (short for if-then-else) |
~ | Unary bitwise complement |
<< | Signed left shift |
>> | Signed right shift |
>>> | Unsigned right shift |
^ | Bitwise exclusiv OR |
Syntax Example:
//Given expressions a, b, c, and d: if !((a && b) && (c || d)) { //Do something. } More Info![]() |
JavaScript logical operators:
&& | and, as in this and that |
|| | or, as in this or that |
! | Not, as in Not This |
JavaScript always short circuits. Given the expression this || that, if this evaluates to true, then that is never executed.
Syntax Example:
//Given expressions a, b, c, and d: if !((a && b) && (c || d)) { //Do something. } More Info![]() |
Perl logical operators:
&& or and | and, as in this and that |
|| or or | or, as in this or that |
! | Not, as in Not This |
Syntax Example:
#Given expressions a, b, c, and d: if !((a && b) && (c || d)) { #Do something. } More Info![]() |
PHP logical operators:
and, && | and, as in this and that |
or, || | or, as in this or that |
! | Not, as in Not This |
Xor | either or, as in this or that but not both |
Syntax Example:
#Given expressions a, b, c, and d: if !((a && b) && (c || d)) { #Do something. }; More Info![]() |
VB Classic logical operators:
and | and, as in this and that |
or | or, as in this or that |
Not | Not, as in Not This |
VB Classic never short circuits. Given the expression this or that as well as this and that, if this evaluates to false, then that is still executed.
Syntax Example:'Given expressions a, b, c, and d: If Not (a and b) and (c or d) Then 'Do something. End If |
You can use the not operator in many contexts. One of my favorite uses for it is to toggle boolean properities with a single line of code:
BooleanProperty = Not BooleanProperty
The following demo uses the not operator to toggle the visible property of a PictureBox from a button.
In the following example, if VB Classic supported short circuting, the That function would never execute. It's interesting to note that VB.Net has introduced two new operators to support short cicuiting: AndAlso and OrElse but you'll have to move to VB.Net to take advantage of them.
Function This()
MsgBox ("The This function executed.")
This = False
End Function
Function That()
MsgBox ("The That function executed!")
That = True
End Function
Private Sub Command0_Click()
'Notice both the This and That functions execute
'even though the This Function returned False.
If This And That Then
MsgBox ("hi")
End If
End Sub
The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.
1 Beginner Level Question
1 Intermediate Level Question
![]() |
VB Classic Logical Operators (and, or, not) |
VB.Net logical operators:
And | and, as in this and that | No Short Circuit |
AndAlso | and, as in this and that | short circuits |
Or | or, as in this or that | No Short Circuit |
OrElse | or, as in this or that | short circuits |
Not | Not, as in Not This | |
Xor | either or, as in this or that but not both |
Syntax Example:
'Given expressions a, b, c, and d: If Not (a and b) and (c or d) Then 'Do something. End If
|
Go ahead! Use Us! | Call: 916-726-5675 | Or visit our new sales site: www.prestwood.com |
ACCOUNT OVERVIEW:
|
CONTACT US:
Office Hours: 8am-5pm | Mon thru Fri
916-726-5675 (office)
916-726-5676 (fax)
916-595-5675 (text msg)
8421 Auburn Blvd, STE 256
Citrus Heights, CA 95610
|
|
©1995-2025 Prestwood IT Solutions.
[Security & Privacy]
|