Retrieve Bit Status (RTVBITSXCL)
The Retrieve Bit Status (RTVBITSXCL) command retrieve the status of one or more bits within a byte of data.
This function is also available with command RTVBITSTS in library VC2XCL. Any use of this alternative command name should be library qualified in case the i operating system were to use this command name in a future release.
| Keyword | Description | Choices | Notes |
| BYTE |
Byte to test |
Character value |
Required, Positional 1 |
| FIRST |
Status of first bit |
Logical value |
Optional, Positional 2 |
| SECOND |
Status of second bit |
Logical value |
Optional |
| THIRD |
Status of third bit |
Logical value |
Optional |
| FOURTH |
Status of fourth bit |
Logical value |
Optional |
| FIFTH |
Status of fifth bit |
Logical value |
Optional |
| SIXTH |
Status of sixth bit |
Logical value |
Optional |
| SEVENTH |
Status of seventh bit |
Logical value |
Optional |
| EIGHTH |
Status of eighth bit |
Logical value |
Optional |
Byte to test (BYTE)
Specifies the byte of data to be used when determining the bit status. This parameter can be specified as a literal value, a CL variable name, or an expression using builtin functions such as %sst.
This is a required parameter.
- character-value
- Specify the byte of data.
Status of first bit (FIRST)
Specifies the CL logical variable to set based on the corresponding bit of the BYTE value. If the corresponding bit is on the variable will be set to ON or true. If the corresponding bit is off the variable will be set to OFF or false.
- logical-value
- Specify the CL variable to receive the bit status.
Status of second bit (SECOND)
Specifies the CL logical variable to set based on the corresponding bit of the BYTE value. If the corresponding bit is on the variable will be set to ON or true. If the corresponding bit is off the variable will be set to OFF or false.
- logical-value
- Specify the CL variable to receive the bit status.
Status of third bit (THIRD)
Specifies the CL logical variable to set based on the corresponding bit of the BYTE value. If the corresponding bit is on the variable will be set to ON or true. If the corresponding bit is off the variable will be set to OFF or false.
- logical-value
- Specify the CL variable to receive the bit status.
Status of fourth bit (FOURTH)
Specifies the CL logical variable to set based on the corresponding bit of the BYTE value. If the corresponding bit is on the variable will be set to ON or true. If the corresponding bit is off the variable will be set to OFF or false.
- logical-value
- Specify the CL variable to receive the bit status.
Status of fifth bit (FIFTH)
Specifies the CL logical variable to set based on the corresponding bit of the BYTE value. If the corresponding bit is on the variable will be set to ON or true. If the corresponding bit is off the variable will be set to OFF or false.
- logical-value
- Specify the CL variable to receive the bit status.
Status of sixth bit (SIXTH)
Specifies the CL logical variable to set based on the corresponding bit of the BYTE value. If the corresponding bit is on the variable will be set to ON or true. If the corresponding bit is off the variable will be set to OFF or false.
- logical-value
- Specify the CL variable to receive the bit status.
Status of seventh bit (SEVENTH)
Specifies the CL logical variable to set based on the corresponding bit of the BYTE value. If the corresponding bit is on the variable will be set to ON or true. If the corresponding bit is off the variable will be set to OFF or false.
- logical-value
- Specify the CL variable to receive the bit status.
Status of eighth bit (EIGHTH)
Specifies the CL logical variable to set based on the corresponding bit of the BYTE value. If the corresponding bit is on the variable will be set to ON or true. If the corresponding bit is off the variable will be set to OFF or false.
- logical-value
- Specify the CL variable to receive the bit status.
Examples for RTVBITSXCL
Example 1: Testing One Bit For ON
Dcl Var(&Char) Type(*Char) Len(1) Value(X'08')
Dcl Var(&Flag1) Type(*Lgl)
RtvBitSXCL Byte(&Char) Fifth(&Flag1)
If Cond(&Flag1) Then( +
SndPgmMsg Msg('Bit is on'))
Else Cmd(SndPgmMsg Msg('Bit is off'))
This example tests the fifth bit of the CL variable &Char. A hex value of x'08' corresponds to the bit pattern b'00001000' so the fifth bit is on. The message 'Bit is on' will be sent.
Example 2: Testing Multiple Bits
Dcl Var(&Char3) Type(*Char) Len(3) Value(X'444342')
Dcl Var(&Flag1) Type(*Lgl)
Dcl Var(&Flag2) Type(*Lgl)
Dcl Var(&Flag3) Type(*Lgl)
RtvBitSXCL Byte(%Sst(&Char3 2 1)) Fifth(&Flag1) +
Seventh(&Flag2) Eighth(&Flag3)
If Cond((*Not &Flag1) *And (&Flag2) *And +
(&Flag3)) Then(Do)
This example tests the fifth, seventh, and eighth bit of the second byte of CL variable &Char3. If the fifth bit is off, the seventh bit is on, and the eighth bit is on then the Do group is run. As the second byte is x'43' corresponding to the bit pattern b'01000011' the Do group will be run.
Error messages for RTVBITSXCL
*ESCAPE Messages
- XCL9002
- Function did not complete. See previously listed messages related to possible user errors.
- XCL9003
- Function did not complete. See previously listed messages for possible cause.
- XCL9004
- Function did not complete. See previously listed messages for possible cause.
|