Set Bit in a Num Gate value

Discussion about Code Builder Builder and Winlog language support.
user1

Set Bit in a Num Gate value

Postby user1 » Tue Mar 09, 2010 10:16 am

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

Postby Lorenzo » Tue Mar 09, 2010 3:01 pm

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


Return to “Code - Code Builder”

Who is online

Users browsing this forum: No registered users and 1 guest