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.

Compress Character Data PDF Print E-mail

Compress Character Data (CPRCHRXCL)

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

The Compress Character Data (CPRCHRXCL) command compresses the character values 0 to 9 and A to F to hexadecimal nibbles.

This function is also available with command CPRCHR 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 of bytes to compress Integer, *ALL Optional
Top

Character variable (VAR)

Specifies the CL variable to receive the compressed character value. When the BASVAR parameter is not specified this CL variable is also used to determine the character values to compress.

This is a required parameter.

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

Base variable (BASVAR)

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

character-value
Specify the CL variable containing the character values to be compressed. The character values must be in the range of 0 to 9 and A to F.
Top

Number of bytes to compress (LEN)

Specifies the number of character values to be compressed. If an odd number of characters is specified then the last 4 bits of the last character generated in the VAR parameter will be set to 0 (b'0000').

If the declared length of the VAR parameter is less than the generated compressed value then only those hexadecimal values that would fit are returned. If the declared length of the VAR parameter is greater then the generated compressed value then remaining bytes of the VAR parameter are left as is.

*ALL
All bytes of the provided character string variable will be compressed.
integer
Specify the number of characters to be compressed.
Top

Examples for CPRCHRXCL

Example 1: Generating Hex Values

 

Dcl        Var(&Source)  Type(*Char) Len(10) +
             Value('c1c2c3c4c5')
Dcl        Var(&Target5) Type(*Char) Len(5)
CprChrXCL  Var(&Target5) BasVar(&Source)

 

This example compresses the character values 'C1C2C3C4C5' to the hexadecimal value x'C1C2C3C4C5'. This hex value corresponds to the characters 'ABCDE'.

Example 1: Generating Partial Hex Values

 

Dcl        Var(&Source)   Type(*Char) Len(10) +
             Value('c1c2c3c4c5')
Dcl        Var(&Target10) Type(*Char) Len(10) +
             Value('0123456789')
CprChrXCL  Var(&Target10) BasVar(&Source)

 

This example compresses the character values 'C1C2C3C4C5' into the first 5 bytes of the CL variable &Target10. The remaining 5 bytes of &Target10 are left as is. After the CPRCHRXCL command has run the hex value of &Target10 is x'C1C2C3C4C5F4F6F7F8F9' which corresponds to the characters 'ABCDE56789'.

Top

Error messages for CPRCHRXCL

*ESCAPE Messages

XCL500F
Invalid character found in BASVAL parameter.
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