The Decompress Character Data (DCPCHRXCL) command decompresses hexadecimal nibbles (4-bit values) to the corresponding character forms 0 to 9 and A to F.
This function is also available with command DCPCHR 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.
Number nibbles to decompress (LEN)
Specifies the number of nibbles (4-bit values) to be converted to character form.
If the declared length of the VAR parameter is less than the generated decompressed value then only those character values that would fit are returned. If the declared length of the VAR parameter is greater then the generated decompressed value then remaining bytes of the VAR parameter are left as is.
- *ALL
- All nibbles of the provided character string are converted to character values.
- integer
- Specify the number of nibbles to be converted to character values.
Examples for DCPCHRXCL
Example 1: Decompress CL Variable
Dcl Var(&Source) Type(*Char) Len(5) +
Value('ABCDE')
Dcl Var(&Target) Type(*Char) Len(10)
DcpChrXCL Var(&Target) BasVar(&Source)
This example decompresses the character value 'ABCDE'. After the DCPCHRXCL command runs the value of CL variable &Target will be the character value 'C1C2C3C4C5' where C1 is the hex value for capital A, C2 the hex value for capital B, etc.
Example 2: Decompress Subset of a Variable
Dcl Var(&Source) Type(*Char) Len(5) +
Value('ABCDE')
Dcl Var(&Target) Type(*Char) Len(10)
DcpChrXCL Var(&Target) BasVar(&Source) Len(3)
This command decompresses the first 3 nibbles (4-bit values) of the character value 'ABCDE'. After the DCPCHRXCL command runs the value of CL variable &Target will be the character value 'C1C ' where C1 is the hex value for capital A and C is the first 4 bits of C2. C2 is the hex value for capital B.
Example 3: Decompress Application
Pgm Parm(&String)
Dcl Var(&String) Type(*Char) Len(10)
Dcl Var(&Nibbles) Type(*Char) Len(20)
DcpChrXCL Var(&Nibbles) BasVar(&String)
SndPgmMsg Msg('The hex value of' *BCat &String *BCat +
'is x:' *Cat &Nibbles)
EndPgm
This example program accepts a parameter of up to 10 bytes in length. The parameter value is decompressed and the resulting value displayed. Calling this program with a parameter value of ABC will result in the message:
The hex value of ABC is x:C1C2C340404040404040
The trailing '40404040404040' represents the seven trailing blanks of the input parameter 'ABC '. To remove these blanks from the displayed message you can use the Retrieve Data Length (RTVDTALXCL) command. Using this program:
Pgm Parm(&String)
Dcl Var(&String) Type(*Char) Len(10)
Dcl Var(&Nibbles) Type(*Char) Len(20)
Dcl Var(&Nbr) Type(*Int)
RtvDtaLXCL Var(&String) Len(&Nbr)
ChgVar Var(&Nbr) Value(&Nbr * 2)
DcpChrXCL Var(&Nibbles) BasVar(&String) Len(&Nbr)
SndPgmMsg Msg('The hex value of' *BCat &String *BCat +
'is x:' *Cat &Nibbles)
EndPgm
will result in the following message being displayed
The hex value of ABC is x:C1C2C3
The multiplication by 2 is due to RTVDTALXCL returning the number of bytes while DCPCHRXCL expects the LEN parameter to be specified in nibbles.