Xojo videos give you an in depth look at various introductory concepts. Introduction to Programming with Xojo is a free book that's a great introduction to programming for just about anyone. When you complete the book you will understand the fundamentals of programming and be on your way to creating your own apps. While you will be using Xojo to learn programming, the concepts introduced are applicable to any. With Xojo, you can create desktop and console apps for your Raspberry Pi all from a slick integrated development environment using drag and drop, along with the simple and straight-forward Xojo programming language. Plus, Xojo is cross-platform and multi-platform, so your apps can also easily work on Windows, macOS, Linux and the web.
Google uses cookies and data to:- Deliver and maintain services, like tracking outages and protecting against spam, fraud, and abuse
- Measure audience engagement and site statistics to understand how our services are used
- Improve the quality of our services and develop new ones
- Deliver and measure the effectiveness of ads
- Show personalized content, depending on your settings
- Show personalized or generic ads, depending on your settings, on Google and across the web
Click 'Customize' to review options, including controls to reject the use of cookies for personalization and information about browser-level controls to reject some or all cookies for other uses. You can also visit g.co/privacytools anytime.
From Xojo Documentation
Used to perform a logical comparison of two boolean expressions and a bitwise And comparison of two integer expressions.
Usage
result = expression1Andexpression2
Part | Description |
---|---|
result | A Boolean if expression1 and expression2 are booleans; an integer if expression1 and expression2 are integers. |
expression1 | Any valid boolean or integer expression. The data types of expression1 and expression2 must match. |
expression2 | Any valid boolean or integer expression. The data types of expression1 and expression2 must match. |
Notes
The And operator is overloaded. You can pass either two booleans or two integers. If you pass two booleans, And performs a logical And operation and returns a boolean. If you pass two integers, it performs a bitwise And operation and returns an integer. In this case, it is equivalent to calling the BitAnd method of the Bitwise class.
In the first instance, if both boolean expressions evaluate to True, then result is True. If either expression evaluates to False then result is False.
The truth table for logical operators is shown below.
Expression1 | Expression2 | And | Or | Xor |
---|---|---|---|---|
True | True | True | True | False |
True | False | False | True | True |
False | True | False | True | True |
False | False | False | False | False |
Xojo Youtube
If you pass two integers, And returns an integer that is the result of comparing each bit of the two integers and assigning 1 to the bit position in the integer returned if both bits in the same position in the integers passed are 1. Otherwise, 0 is assigned to the bit position.
The following table gives the results for bitwise operators.
Integer1 | Integer2 | And | Or | Xor |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | 1 |
1 | 0 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 0 |
The Operator_And function can be used to define the And operator for classes.
Use within If Statements
Zojo Youtube
When used within an If..Then statement, once the first expression results to False, none of the subsequent expressions are evaluated. In this example, the IsValid method is not called because the first expression is False. This is referred to as short-circuit evaluation:
If b And IsValid('value') Then// IsValid does not get called
...
End If
Sample Code
This example uses the And operator to perform logical comparisons.
Var b AsBoolean
Var c AsBoolean// defaults to False
Var d AsBoolean// defaults to False
a = True
b = True
d = a And b // Returns True
d = a And c // Returns False
Using And with Integer values:
Var i2 AsInteger = 5
Var result AsInteger
result = i1 And i2 // result = 4
Xojo Tutorial Youtube
To understand how the above evaluates to 4, look at the binary values. The value of 4 is '100' in binary. The value of 5 is '101' binary. If you 'And' those two binary values together then only the first '1' is in common. So the result is '100', which is 4.
The And operator is overloaded. You can pass either two booleans or two integers. If you pass two booleans, And performs a logical And operation and returns a boolean. If you pass two integers, it performs a bitwise And operation and returns an integer. In this case, it is equivalent to calling the BitAnd method of the Bitwise class.
In the first instance, if both boolean expressions evaluate to True, then result is True. If either expression evaluates to False then result is False.
The truth table for logical operators is shown below.
Expression1 | Expression2 | And | Or | Xor |
---|---|---|---|---|
True | True | True | True | False |
True | False | False | True | True |
False | True | False | True | True |
False | False | False | False | False |
Xojo Youtube
If you pass two integers, And returns an integer that is the result of comparing each bit of the two integers and assigning 1 to the bit position in the integer returned if both bits in the same position in the integers passed are 1. Otherwise, 0 is assigned to the bit position.
The following table gives the results for bitwise operators.
Integer1 | Integer2 | And | Or | Xor |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | 1 |
1 | 0 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 0 |
The Operator_And function can be used to define the And operator for classes.
Use within If Statements
Zojo Youtube
When used within an If..Then statement, once the first expression results to False, none of the subsequent expressions are evaluated. In this example, the IsValid method is not called because the first expression is False. This is referred to as short-circuit evaluation:
If b And IsValid('value') Then// IsValid does not get called
...
End If
Sample Code
This example uses the And operator to perform logical comparisons.
Var b AsBoolean
Var c AsBoolean// defaults to False
Var d AsBoolean// defaults to False
a = True
b = True
d = a And b // Returns True
d = a And c // Returns False
Using And with Integer values:
Var i2 AsInteger = 5
Var result AsInteger
result = i1 And i2 // result = 4
Xojo Tutorial Youtube
To understand how the above evaluates to 4, look at the binary values. The value of 4 is '100' in binary. The value of 5 is '101' binary. If you 'And' those two binary values together then only the first '1' is in common. So the result is '100', which is 4.
See Also
Xojo Videos
Not, Or, Xor operators; Bitwise class; Operator_And function; Operator precedence