Release the NEW Power of CL

Release the NEW Power of CL

Name:

Email:

Programming Services

Do you need a program written?

Bruce Vining Services can provide highly experienced IBM i developers to supplement your staff with short term contracts. We don't do general ledger but if you are looking for custom solutions involving system functions such as database, communications, security, encryption, print, and work management you will find your answers at Bruce Vining Services.

Retrieve Bit Status PDF Print E-mail

Retrieve Bit Status (RTVBITSXCL)

Where allowed to run:
  • Batch program (*BPGM)
  • Interactive program (*IPGM)
Threadsafe: Yes
Parameters
Examples
Error messages

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.

Top

Parameters

KeywordDescriptionChoicesNotes
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
Top

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.
Top

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.
Top

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.
Top

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.
Top

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.
Top

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.
Top

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.
Top

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.
Top

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.
Top

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.

Top

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.
Top
 
Joomla 1.5 Templates by Joomlashack