Bit Procedure |
Version 5 |
Returns or sets the specified bits value.
[ dwValue = ] Bit ( dw, lBit, [lValue] )
The Bit procedure syntax has the following parts:
Name |
Type |
Description |
dwValue |
DWord |
Returned value: either bit value, 0 or 1, or if lValue is provided - resulting value of the bit operation |
dw |
Val DWord |
Input value in DWord |
lBit |
Val Long |
Bit position, 0 based, possible values is 0 to 31. |
lValue |
[Val Long] |
Value to set 0 or 1. If this parameter is omitted, dwValue returns bit value of given position. If the parameter is provided, dwValue returns dw value with the lBit bit set or cleared. |
Returns or sets bit value, either 0 or 1 of given bit position. If the lValue parameter is missing, then it returns bit value. Otherwise, it returns the resulting value of bit operation.
Use this function to get or set a bit from an integer.
v10 Use the Bits function to read and write bit fields similar to C programming language.
The following example shows using the Bit function to get and set values:
dw=0x100
print bit(dw, 8) ! returns 1 - value of bit 8
dw=bit(dw, 1, 1) ! sets bit 1 to 1, returns 258 (0x102),