RPG/400 Help

BITON (Set Bits On)

*---------*---------------*-----------------*----------------*---------------*
|   CODE  |    FACTOR 1   |     FACTOR 2    |     RESULT     |  INDICATORS   |
|         |               |                 |      FIELD     |               |
*---------*---------------*-----------------*----------------*---------------*
| BITON   |               | Bit numbers     | Character      |               |
|         |               |                 | field          |               |
*---------*---------------*-----------------*----------------*---------------*

The BITON operation causes bits identified in factor 2 to be set on (set to 1) in the result field. Bits not identified in factor 2 remain unchanged. Therefore, when using BITON to format a character, you should use both BITON and BITOF :  BITON to specify the bits to be set on (=1), and BITOF 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.

Factor 2 can contain:

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.

Figure "BITON and BITOF Operations" illustrates uses of the BITON operation.

BITON and BITOF Examples

Figure 8. BITON and BITOF Operations

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
I..............Namedconstant+++++++++C.........Fldnme......... ....
I              '01234567'            C         BITNC
I              X'0F'                 C         HEXNC
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C*  Before the operations are processed, the bit settings are:
C*                FLDA = 00000000
C*                FLDB = 00000000
C*                FLDC = 11111111
C*                FLDD = 11000000
C*                FLDE = 11000000
C*                FLDF = 10000001
C*                FLDG = 11111111                       AFTER
C*                FLDH = 00000000                     OPERATIONS
C*                FLDI = 11001010                     ----------
C*
C                     BITON'04567'   FLDA             = 10001111
C                     BITON'3'       FLDB             = 00010000
C                     BITON'3'       FLDC             = 11111111
C                     BITON'3'       FLDD             = 11010000
C                     BITONFLDE      FLDF             = 11000001
C                     BITONX'01'     FLDH             = 00000001
C*
C                     BITOF'0'       FLDG             = 01111111
C*
C                     BITOFBITNC     FLDI             = 00001110
C                     BITONHEXNC     FLDI             = 00001111


[ Top of Page | Previous Page | Next Page | Table of Contents ]