Promotic
WikipediaLinkedInYoutubeTwitterFacebook

SetBit - method of the Pm object

Description:
Changing a bit of the variable.
Syntax:
Variant SetBit(Variant vFrom, Long nIndex, Boolean bValue)
Parameters:
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).
Note:
It doesn't change the value of the vFrom variable directly but it returns new value that can be put into the variable.
 
In the JavaScript 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 object.

This method is also functional in Web panels.

Example:
Sets the 20th bit In the BitMask variable
JavaScriptVBScriptSelect and copy to clipboard

BitMask = Pm.SetBit(BitMask, 20, true);
CLng 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.

History:
Pm8.02.13: Sometimes the bit range was not tested correctly causing some writing outside the range.
Pm8.02.09: Available for Web panels.
PROMOTIC 9.0.15 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- LN2
- PI
- Pow
- SetBit
 
 
- Sin
- Tan
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice