Set Bit in a Num Gate value

Discussion about Code Builder Builder and Winlog language support.
Post Reply
user1

Set Bit in a Num Gate value

Post by user1 »

Is it possible to set a specific bit in a Num Gate Value in code?
You can check the bit status in a Num Gate Value with the Get Bit command?
Can you give me an example if this is possible.
Thank you for support.
Lorenzo
Posts: 11
Joined: Tue Nov 17, 2009 3:52 pm

Re: Set Bit in a Num Gate value

Post by Lorenzo »

Yes, here it is a Winlog code example:

Function void CheckBit()
int Value;
Value=GetNumGateValue("N",1);
if GetBit(Value,2)==1 then
MessageBox("Bit 2=1","");
else
MessageBox("Bit 2=0","");
end
end


Function void SetBit()
int Value;
Value=GetNumGateValue("N",1);
Value=SetBit(Value,2);
SetNumGateValue("N",1,Value);
end
Post Reply