CHARADD()

Adds corresponding ASCII value of two strings

Syntax

CHARADD (<[@]cString1>, <cString2>) --> cAddString

Arguments

<[@]cString1> first string <cString2> second string

Returns

<cAddString> string with added ASCII values

Description

The CHARADD() function constructs a new string from the two strings passed as parameters. To do this, it adds the ASCII values of the corresponding characters of both strings and places a character in the resulting string whose ASCII value equals to that sum (modulo 256). If the first string is passed by reference, the resulting string is stored in <cString1>, too. By setting the CSETREF()-switch to .T., the return value can be omitted. If <cString2> is shorter than <cString1> and the last character of <cString2> has been processed, the function restarts with the first character of <cString2>.
Examples
      ? charadd ("012345678", chr(1)) --> "123456789"
      ? charadd ("123456789", chr(255)) --> "012345678"
      ? charadd ("0000", chr(0)+chr(1)+chr(2)+chr(3)) --> "0123"
Tests
      charadd ("012345678", chr(1)) == "123456789"
      charadd ("012345678", chr(1)+chr(2)) == "133557799"
      charadd ("123456789", chr(255)) == "012345678"
      charadd ("123456789", chr(255)+chr(254)) == "002244668"
Status

Ready

Compliance

CHARADD() is compatible with CT3's CHARADD().

Platforms

All

Files

Source is charop.c, library is ct3.

See Also