SetBit - method of the Pm object
Changing a bit of the variable.
Variant SetBit(Variant vFrom, Long nIndex, Boolean bValue)
|vFrom||(Variant) Value whose bit has to be changed. The value must be integer (Byte, Integer, Long).|
|nIndex||(Long) Index of the bit in the variable (zero-based index).|
|bValue||(Boolean) New value of the bit (true or false).|
It doesn't change the value of the vFrom
variable directly but it returns new value that can be put into the variable.
language, it is better to use the standard bit operators
for reading and setting the bit.
This method is functional also in Macro expression $.expr
and in the onDraw
event of the PmgCanvas
This method is also functional in Web panels
Sets the 20th bit In the BitMask variable
BitMask = Pm.SetBit(BitMask, 20, true);
is needed when originally the BitMask
was not of the Long
type. If it has been, for example, of the Integer
type, then the 20th bit of the value does not exist and the method would fail.
: Sometimes the bit range was not tested correctly causing some writing outside the range.