GET_BIT
Use the GET_BIT script function to convert a number to binary format and check whether a specific bit is set at a given position in the resulting bit field.
Tip: You can also use this function to inspect the 16-bit MSG_DESCRIPTOR, MSG_LEVEL, and MSG_MISC fields of a z/OS console message, although those fields can also be queried directly with GET_CONSOLE. For more information, see GET_CONSOLE, GET_EVENT_INFO.
Syntax
GET_BIT (Number, Bit Position)
Parameters
| Parameter | Description | Format |
|---|---|---|
| Number | The number to convert to binary format (bit field) | Number or script variable |
| Bit Position | The position within the bit field to check, always counted from the right | Script literal, script variable, or number without quotation marks |
Return Codes
| Return Value | Condition |
|---|---|
| 1 | The bit is set at the specified position |
| 0 | The bit is not set at the specified position |
Examples
The following example checks whether the third bit is set in the binary representation of 6 (bit field 110) and prints the result to the activation report.
: SET &RET# = GET_BIT (6, 3)
: PRINT &RET#
The following example retrieves a component of a z/OS console message and checks bit position 3 in its binary representation.
: SET &RET# = GET_CONSOLE ("MSG_DESCRIPTOR")
: SET &RET# = GET_BIT (&RET# , 3)
See also: