FoxPro Bit Manipulation
Visual FoxPro can manipulate numbers up to the size of a 32-bit
integer as patterns of bits. Here is a list of some of the more
useful commands and functions. Many of them accept extra
optional parameters. Look in the FoxPro Help system for more
information.
Boolean operators
The simplest boolean operator is NOT. This takes a single number
as a parameter. Every bit in the output number is the opposite
of its equivalent in the input parameter. Every zero will be
replaced by a one; every one will be replaced by a zero. FoxPro does
this with the BITNOT function:
| BITNOT(<n1>) |
returns <n1> with every bit inverted. |
Three other boolean operators take two input parameters and return
a single number:
-
AND will produce a 1 only if both input bits are 1.
-
OR will produce a 1 if either or both input bits are 1.
-
XOR will produce a 1 if either but not both input bits are 1.
FoxPro implements these operators with these three functions:
| BITAND(<n1>,<n2>) |
return <n1> AND <n2>. |
| BITOR(<n1>,<n2>) |
return <n1> OR <n2>. |
| BITXOR(<n1>,<n2>) |
return <n1> XOR <n2>. |
Note that each of these three functions can take more than
two parameters.
Other bitwise operators
The following FoxPro commands change or test an individual
bit of a single number:
| BITCLEAR(<n1>,<n2>) |
return <n1> with bit <n2> set to 0. |
| BITSET(<n1>,<n2>) |
return <n1> with bit <n2> set to 1. |
| BITTEST(<n1>,<n2>) |
return .T. if bit <n2> of <n1> is 1. |
The following commands shift the bits of a number left
or right:
| BITLSHIFT(<n1>,<n2>) |
return <n1> with all bits shifted <n2>
places to the left. The leftmost <n2> bits are
set to 0.
|
| BITRSHIFT(<n1>,<n2>) |
return <n1> with all bits shifted <n2>
places to the right. The rightmost <n2> bits
are set to 0.
|
|
Alvechurch Data provide training and development support for businesses using Microsoft FoxPro, Visual FoxPro and Access databases.
Read More
|
The textbox class in Visual FoxPro 9 has a new Autocomplete property which shows the user the previous values that have been entered in that textbox.
Read More
|
FoxPro has always had functions to read and write files at a low level.
Read More
|
Alvechurch Data have fifteen years experience developing databases for small business use.
Read More
|
Details of the training courses offered by Alvechurch Data.
Read More
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|