BITOFF (Set Bits Off)

Free-Form Syntax (not allowed - use the%BITAND and %BITNOT built-in functions. See Figure 3.)
Code Factor 1 Factor 2 Result Field Indicators
BITOFF   Bit numbers Character field      

The BITOFF operation causes bits identified in factor 2 to be set off (set to 0) in the result field. Bits not identified in factor 2 remain unchanged. Therefore, when using BITOFF to format a character, you should use both BITON and BITOFF:  BITON to specify the bits to be set on (=1), and BITOFF to specify the bits to be set off (=0). Unless you explicitly set on or off all the bits in the character, you might not get the character you want.

If you want to assign a particular bit pattern to a character field, use the MOVE (Move) operation with a hexadecimal literal in factor 2.

Factor 2 can contain:
  • Bit numbers 0-7: From 1 to 8 bits can be set off per operation. They are identified by the numbers 0 through 7. (0 is the leftmost bit.) Enclose the bit numbers in apostrophes. For example, to set off bits 0, 2, and 5, enter ‘025’ in factor 2.
  • Field name: You can specify the name of a one-position character field, table element, or array element in factor 2. The bits that are on in the field, table element, or array element are set off in the result field; bits that are off do not affect the result.
  • Hexadecimal literal or named constant: You can specify a 1-byte hexadecimal literal or hexadecimal named constant. Bits that are on in factor 2 are set off in the result field; bits that are off are not affected.
  • Named constant: A character named constant up to eight positions long containing the bit numbers to be set off.

In the result field, specify a one-position character field. It can be an array element if each element in the array is a one-position character field.

For more information, see Bit Operations.

Figure 1. BITOFF Example
 *    Set off bits 0,4,6 in  FieldG.  Leave bits 1,2,3,5,7 unchanged.
 *    Setting off bit 0, which is already off, results in bit 0 remaining off.
 *       Factor 2 = 10001010
 *       FieldG   = 01001111  (before)
 *       FieldG   = 01000101  (after)
C                   BITOFF    '046'         FieldG
 *    Set off bits 0,2,4,6 in FieldI.  Leave bits 1,3,5,7 unchanged.
 *    Setting off bit 2, which is already off, results in bit 2 remaining off.
 *       Factor 2 = 10101010
 *       FieldI   = 11001110  (before)
 *       FieldI   = 01000100  (after)
C                   BITOFF    BITNC         FieldI
 *    HEXNC is equivalent to literal '4567', bit pattern 00001111.
 *    Set off bits 4,5,6,7 in  FieldK.  Leave bits 0,1,2,3 unchanged.
 *       Factor 2 = 11110000
 *       FieldK   = 10000000  (before)
 *       FieldK   = 00000000  (after)
C                   BITOFF    HEXNC2        FieldK
C                   RETURN