Function for setting and reading specific bit

Noah Breece 5 years ago in IQANdesign updated by Thomas Moberg (System support) 5 years ago 2

I realized I was a "bit" to fast on the keyboard. What I am after is a function to easily get a specific bit of a component in QCode, or to set a specific bit of a component in QCode (or statement list).

Suggested function:

GetBitof(component, bit number)

SetBitOf(component, bit number) 


Hello Noah.

You can do this with the help of the bitwise logic.

For example:

Bit6:= component shr(5) band(1)                //getting Bit 6 value

New value:= 1 shl(5) bor(component)        //Setting Bit 6 to 1