Checksum function.
Examples
This example uses mode=0 on strings containing the letters A, B, and C and in each case returns the checksum 198:
write $ZCRC("ABC",0),!
write $ZCRC("CAB",0),!
write $ZCRC("BCA",0),!
The checksum is derived as follows:
write $ASCII("A")+$ASCII("B")+$ASCII("C") /* 65+66+67 = 198 */
This example shows the values returned by each mode for the string “ABC”:
for i=0:1:9 { write "mode ",i," = ",$ZCRC("ABC",i),! }
This example shows how you can use the output of a previous $ZCRC value as the seed for the next calculation. In modes 1 through 7, the CRC of “ABC” is equal to the sequential CRC calculations of “A”, “B”, and “C”, each seeded with the CRC of the previous letter. In modes 8 and 9 (Mumur3 hashes), the CRC calculations are not equal, because Murmur3 does not support chained expressions.
for mode = 1:1:9 {
set crc1 = $zcrc("ABC",mode)
set crc2 = $zcrc("A",mode)
set crc2 = $zcrc("B",mode,crc2)
set crc2 = $zcrc("C",mode,crc2)
write "mode ", mode," ", "crc1 = crc2: ", crc1 = crc2, !
}