Compress Data

CpsData

The CpsData procedure compresses the input value and returns it as a compressed value. The compressed value is usually shorter than the original uncompressed value.

varying-char-value CpsData(
  szUnCompressedData    65535A   Const Varying 
  nRtnLen                  10I 0 Options(*NOPASS)
)

See also: DPSData

Parameters

szUnCompressedData
[input VChar(*) const]  A varying or fixed-length character value whose length is 1 to 65535. The value of this parameter is not modified but the data is compressed and returned to the caller as the return value.
nRtnLen  [optional]
[output int(4) const]  This parameter is modified by the procedure; it is set to the length of the compressed data being returned. This parameter may be used to verify that the length of your receiver variable is long enough to receive the entire compressed data.

Return Value

If the function succeeds, the return value is the a compressed version of the szUnCompressedData parameter. The length of the returned data can be detected by passing a 2nd parameter to this procedure. Also if the returned data is assigned to a variable length field, the field's length is set to the length of the return data.

Example

The following example compresses the text string "Lunar Spacecraft Company" and stores the compressed value in the field named COMPRESS.

.....DName+++++++++++EUDS.......Length+TDc.Functions+++++++++++++++++++++++++
     D Company         S             50A   Inz('Lunar Spacecraft Company')
     D Compress        S             50A   Varying
 
.....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++

     C                   Eval      compress = CpsData(Company)