Read individual bits from a byte in VO

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
User avatar
DPEETERS
Posts: 6
Joined: Sat Mar 04, 2017 2:06 pm

Read individual bits from a byte in VO

Post by DPEETERS »

Hi All,

I need to read the individual state of a bit , can sombody help me on this subject.

thanks,
dirk
User avatar
SHirsch
Posts: 286
Joined: Tue Jan 30, 2018 8:23 am
Location: Germany

Read individual bits from a byte in VO

Post by SHirsch »

Hello Dirk,

a sample

Code: Select all

LOCAL n AS INT
   
n := 3
IF _AND(n,0x01) > 0  //true
   ?"Bit0"
ENDIF
IF _AND(n,0x02) > 0   //true
   ?"Bit1"
ENDIF
IF _AND(n,0x04) > 0  //false
   ?"Bit2"
ENDIF
Stefan
User avatar
SHirsch
Posts: 286
Joined: Tue Jan 30, 2018 8:23 am
Location: Germany

Read individual bits from a byte in VO

Post by SHirsch »

Hi Dirk,

if you like shifting bits

Code: Select all

   LOCAL n AS INT
   
   n := 3
   IF _AND(n,1) > 0  //true
      ?"Bit0"
   ENDIF
   IF _AND(n>>1,1) > 0 //true
      ?"Bit1"
   ENDIF
   IF _AND(n>>2,1) > 0  //false
      ?"Bit2"
   ENDIF
Stefan
User avatar
DPEETERS
Posts: 6
Joined: Sat Mar 04, 2017 2:06 pm

Read individual bits from a byte in VO

Post by DPEETERS »

Hi Stefan,

thanks for the reply i give it a try.

regards,
dirk
Post Reply