MASK( ) function
Performs a bitwise AND operation on the first bytes of two character strings.
Syntax
MASK(character_value, character_mask)
Parameters
| Name | Type | Description | 
|---|---|---|
| character_value | character | 
                                                                         The string with the byte to test.  | 
                                                                
| character_mask | character | 
                                                                         The string with the byte to test against (the mask value).  | 
                                                                
Output
Character. The output is the character representation of the binary result of the bitwise AND operation.
Examples
Basic examples
Returns "2" (00110010), the result of a bitwise AND of 3 (00110011) and 6 (00110110):
MASK("3", "6")
                                                        Remarks
When to use MASK( )
Use MASK( ) to identify specific bit patterns in a byte of data, including whether or not a particular bit is set to 1.
How it works
The MASK( ) function performs a bitwise AND operation on the binary representations of the first characters of character_value and character_mask. The two comparison bytes are compared one bit at a time, resulting in a third binary value.
The result of each comparison of corresponding bits is either 1 or 0:
| character_value bit | character_mask bit | Result | 
|---|---|---|
| 0 | 0 | 0 | 
| 0 | 1 | 0 | 
| 1 | 0 | 0 | 
| 1 | 1 | 1 | 
Comparison strings longer than one byte
If either comparison string is longer than one byte, subsequent characters are ignored.