Bit-Wise operators allow you to utilize bitmasks within your program.
Bit-Wise operators act just like their logical counterparts (AND,OR,XOR) except that instead of returning TRUE or FALSE, they return the actual result.
To facilitate the use of these operators, LET recognizes the hexadecimal notation of 0X? for expressing a numerical constant. The ? character is from 1 to 8 hexadecimal characters (0‑F).
Table 46. Bit-Wise Operators
In addition to BitAND, BitOR, and BitXOR, you can use the HEX function. The HEX function takes a numerical argument and returns a string, in the form of 0X?, which is the hexadecimal representation of the argument.
To prevent any loss of precision, declare the arguments to the Bit-Wise operators and the HEX function as an INTEGER.
Sample program: ! ! Validation test for Bit-Wise LET operators ! begin-setup declare-variable integer #mask end-declare end-setup
begin-program let #mask = 0x1000 if not (#mask BitAND 0x1000) let $mask = hex(#mask) show 'impossible ' $mask ' BitAND 0x1000 failed' end-if if (#mask BitOR 0x1000) <> 0x1000 let $mask = hex(#mask) show 'impossible ' $mask ' BitOR 0x1000 failed' end-if if (#mask BitXOR 0x1000) let $mask = hex(#mask) show 'impossible ' $mask ' BitXOR 0x1000 failed' end-if let #Mask = 0 if (#mask BitXOR 0x1000) <> 0x1000 let $mask = hex(#Mask) show 'impossible ' $mask ' BitXOR 0x1000 failed' end-if let $mask = hex(0xffffffff) if $mask <> '0xffffffff' show 'impossible ' $mask ' <> 0xffffffff' end-if let $mask = hex(0x12345678) If $Mask <> '0x12345678' show 'impossible ' $mask ' <> 0x12345678' end-if let $mask = hex(0xabcdef12) if $mask <> '0xabcdef12' show 'impossible ' $mask ' <> 0xabcdef12' end-if end-program