And
From REALbasicWiki
The and operator operates on either Booleans or Integers (support for Integer was added in REALbasic 2007r2).
When operating on Booleans, and is the standard Boolean operation, defined on values as follows.
true and true = true true and false = false false and true = false false and false = false
When operating on Integers, and operates bitwise on the operands. To see what this means, we first provide a table for operation on a single bit.
1 and 1 = 1 1 and 0 = 0 0 and 1 = 0 0 and 0 = 0
That is, 1 corresponds to true and 0 corresponds to false.
On arbitrary integers, and operates on the bits in the base 2 representations of the operands. Here is an example.
3 and 5 = 0011 and 0101
= (0 and 0)*8 + (0 and 1)*4 + (1 and 0)*2 + (1 and 1)*1
= 1
[edit] Short-Circuit Evaluation
The and operator performs short-circuit evaluation. This means that if the first operand evaluates to false, then and returns false without evaluating the second operand. For example, consider the following code.
dim f as FolderItem = GetFolderItem("/path/to/ruin", FolderItem.PathTypeShell)
if f<>nil and f.Exists then
//...you can use f here
else
MsgBox "f is nil or does not exists"
end if
If the expression f<>nil evaluates to false, then And returns false without evaluating the second expression f.Exists, and so you will not get a NilObjectException when f is nil. But beware that the following code is not exception-safe.
if GetFolderItem("/path/to/ruin", FolderItem.PathTypeShell)<>nil and GetFolderItem("/path/to/ruin", FolderItem.PathTypeShell).Exists then
This code can result in the raising of a NilObjectException because GetFolderItem is a function that may return Nil the second time you call it.
