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.

Decompress Character Data PDF Print E-mail

Decompress Character Data (DCPCHRXCL)

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

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.

Top

Parameters

KeywordDescriptionChoicesNotes
VAR Character variable Character value Required, Positional 1
BASVAR Base variable Character value Optional, Positional 2
LEN Number nibbles to decompress Integer, *ALL Optional
Top

Character variable (VAR)

Specifies the CL variable to receive the decompressed character values. When the BASVAR parameter is not specified this CL variable is also used to determine the character values to be decompressed.

This is a required parameter.

character-value
Specify the name of the CL variable to receive the decompressed character values.
Top

Base variable (BASVAR)

Specifies the character values to be decompressed. If this parameter is not specified then the VAR parameter is used to determine the characters to be decompressed.

character-value
Specify the CL variable containing the character values to be decompressed.
Top

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

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.

Top

Error messages for DCPCHRXCL

*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