Skip to content

LRC

Longitudinal Redundancy Check

This string function conducts a byte-by-byte logical XOR operation on each byte in the given string and returns a one-byte longitudinal redundancy check character.

LRC (string-value [,ERR=line-ref|,ERC=error-code])
string-value
is any string.
line-ref
is the program line number or label to branch to if an error is produced by this function.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

If an argument has a single byte, it is compared with the null string ($00$).

Note that XOR requires 2 strings of identical length and compares one string to the other while LRC uses only one string and compares bytes within that string to each other.

The result of this function is normally used to check for errors in data transmission along with the CRC function.

LRC ("A")

returns the character “A” (0100 0001) which is the result of the exclusive OR of “A” (0100 0001) and the null string (0000 0000).

LRC ("AA")

returns the null character (0000 0000), which is the result of the exclusive OR of “A” (0100 0001) with itself.

LET X$ = LRC ("AAA")

returns the same result as the first example and assigns the value to X$.

LET X$ = LRC (B$+C$)

If B$ = “A” and C$ = “AA”, has the same effect as the previous example.

CRC and XOR functions

From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF