CHECKSUM()

CHECKSUM()

Top  Previous  Next

 

The CHECKSUM() function returns a checksum value for supplied data.

 

 

Format

 

CHECKSUM(data {, mode})

 

where

 

datais the character string for which a checksum is to be calculated.

 

modespecifies the algorithm to be used. Defaults to 0 if omitted.

 

 

The CHECKSUM() function calculates a cyclic redundancy checksum (CRC) value for the supplied data item. Note that the various multivalue products implement this function using different algorithms, not all of which are available in QM. The default algorithm used by QM is a simple rotate and merge but several alternative algorithms used by other software packages are available by use of the optional mode argument.

 

The checksum value produced by an ECS mode system for data that contains only characters from the 8-bit set is identical to that produced for the same data on a non-ECS mode system. The CRC algorithms are usually based on byte structured data. Applications using ECS mode may sometimes need to use the BSL or BSH conversion code to form a hardware byte order specific representation of the data prior to use of the CHECKSUM() function.

 

If data is a null string or mode is invalid, the CHECKSUM() function returns zero.

 

 

Algorithms

 

0

CRC$QM

QM default rotate and merge algorithm

1

CRC$XMODEM

CCITT XModem (as used by some other multivalue products, e.g. UniVerse)

2

CRC$CCITT.FALSE

CCITT with 0xFFFF initialiser

3

CRC$CCITT.AUG

CCITT with 0x1D0F initialiser

4

CRC$KERMIT

CCITT Kermit

5

CRC$16

CRC-16

6

CRC$MODBUS

CCITT Modbus

7

CRC$BYTE

Simple byte addition

8

CRC$DNP

CRC-DNP (IEEE 1815)

9

CRC$32

CRC-32

10

CRC$16.SICK

CRC-16 "Sick" variant

11

CRC$PARITY

Longitudinal byte parity (Bitwise exclusive OR of all bytes)

 

 

Examples

 

DISPLAY CHECKSUM(REC)

 

This statement displays a checksum value for the data in the REC variable using the default algorithm.

 

 

DISPLAY CHECKSUM(REC, CRC$CMODEM)

 

This statement displays a checksum value for the data in the REC variable using the CCITT-XModem algorithm.

 

 

See also:

MD5()