Skip to main content

$ZCYC (ObjectScript)

Returns the cyclical-redundancy check value for the given string.

Synopsis

$ZCYC(string)
$ZC(string)

Argument

Argument Description
string A string.

Description

$ZCYC(string) 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.

$ZCYC calculates the check value by performing an exclusive OR (XOR) on the binary representations of all the characters in the string.

Note that the $ZCYC value of an 8-bit string is identical to the $ZCRC mode 1 value.

Argument

string

A string. Can be specified as a value, a variable, or an expression. String values are enclosed in quotation marks.

Example

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

See Also

FeedbackOpens in a new tab