Caché ObjectScript Reference
Cyclical-redundancy check for data integrity.
) computes and returns the cyclical-redundancy check value for the string. It allows two intercommunicating programs to check for data integrity.
The sending program transmits a piece of data along with a matching check value that it calculates using $ZCYC
. The receiving program verifies the transmitted data by using $ZCYC
to calculate its check value. If the two check values match, the received data is the same as the sent data.
calculates the check value by performing an exclusive OR
(XOR) on the binary representations of all the characters in the string.
Use caution when transmitting data between 8-bit and Unicode (16-bit) implementations of Caché; if a data string does not contain any wide characters, the cyclical-redundancy check values should match.
Note that the $ZCYC value of an 8-bit string is identical to the $ZCRC mode 1 value.
A string. Can be specified as a value, a variable, or an expression. String values are enclosed in quotation marks.
In this example, the first $ZCYC
returns 65; the second returns 3; and the third returns 64.
SET x= $ZCYC("A")
; 1000001 (only one character; no XOR )
SET y= $ZCYC("AB")
; 1000001 XOR 1000010 -> 0000011
SET z= $ZCYC("ABC")
; 1000001 XOR 1000010 -> 0000011 | 1000011 -> 100000
WRITE !,"x=",x," y=",y," z=",z