CHECKSUM
Calculates checksum digits.
Syntax
CHECKSUM(string,[checktype, base, charset])
Arguments
Argument | Description | Default | |
---|---|---|---|
string | The string for which to generate a checksum. Characters in string must match case with characters in charset (that is, A does not equal a, and so on). | None | |
[checktype] | The type of checksum calculation to perform; one of the following: | 1 | |
1 | Sum all digits in string and generate checksum. | ||
2 | Sum all digits in string, multiplying odd-position digits by 2. | ||
3 | Sum all digits in string, multiplying even-position digits by 2. | ||
4 | Sum all digits in string, multiplying odd-position digits by 3. | ||
5 | Sum all digits in string, multiplying even-position digits by 3. | ||
6 | Multiply odd-position digits in string by 2. Sum the digits in the products, then add the odd position digits. | ||
7 | Multiply even-position digits in string by 2. Take the products that result and sum the individual digits in the products. Sum that total and the digits from the odd positions. | ||
[base] | The numeric base, in the range 2 to 50, in which to compute the checksum. If you specify a base less than 2, EngageOne™ Enrichment uses 2. If you specify a base greater than 50, EngageOne™ Enrichment uses 50. |
10 | |
[charset] | The character set to use as a basis for computing the checksum. This string should contain the number of characters specified by base. If the character set you specify contains special (that is, non-alphanumeric) characters, you must enclose the charset value in quotation marks. If your character set contains single quotation marks, enclose the charset value in double quotation marks. If your character set contains double quotation marks, enclose the charset value in single quotation marks. If charset contains more than base characters, EngageOne™ Enrichment uses only the first base characters. If charset contains less than base characters, EngageOne™ Enrichment appends the specified characters with the remainder of the default character set. |
0–9, uppercase A–Z |
Results
Result | Description | |
---|---|---|
Return | The character within charset that corresponds to the checksum value. This is calculated by dividing the result of the checktype calculation by base, then subtracting the remainder from base. | |
%%RC | One of the following: -1 — Bad checktype value. 0 — No error. 1 — The string contains characters not contained in charset. |
|
%%RM | A null string (''). | |
%%RV | The numeric checksum value. |
Examples
Function Call | Sum | Return | %%RC | %%RV |
---|---|---|---|---|
CHECKSUM(015,1,10,) | 6 | 4 | 0 | 4 |
CHECKSUM(AZ1,1,36,) | 46 | Q | 0 | 26 |
CHECKSUM(aZ1,1,36,) | -1 | |||
CHECKSUM(015,2,10,) | 11 | 9 | 0 | 9 |
CHECKSUM(015,3,10,) | 7 | 3 | 0 | 3 |
CHECKSUM(015,4,10,) | 16 | 4 | 0 | 4 |
CHECKSUM(015,5,10,) | 8 | 2 | 0 | 2 |
CHECKSUM(9789,6,10) | 32 | 8 | 0 | 8 |
CHECKSUM(015,7,10,) | 7 | 3 | 0 | 3 |
CHECKSUM(0559,7,10,) | 15 | 5 | 0 | 5 |
CHECKSUM(080,7,10,) | 7 | 3 | 0 | 3 |
Hints
For CHECKSUM(aZ1,1,36,)
, a is not in the default character set. Therefore, the function call is unsuccessful.
For CHECKSUM(0559,7,10,)
, the sum (15) was calculated as follows:
0 x 1 = 0 = 0 5 x 2 = 10 = 1 + 0 = 1 5 x 1 = 5 = 5 9 x 2 = 18 = 1 + 8 = 9 sum = 0 + 1 + 5 + 9 = 15