| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Creates a string from the sum of ASCII codes of two strings.
CharAdd( <cString1> , <cString2> ) --> cResult
The function returns a string by adding the ASCII codes of the individual characters of both input strings.
The function operates until all characters of <cString1> are processed. It distinguishes the following situations:
| 1) | Len( <cString1> ) == Len( <cString2> ) |
| When both input strings are of the same length, the ASCII code of each character in <cString2> is added to the ASCII code of the corresponding character in <cString1>. |
| 2) | Len( <cString1> ) > Len( <cString2> ) |
| When the last character of <cString2> is reached, the function starts over with the first character of <cString2>, until the last character of <cString1> is processed. |
| 3) | Len( <cString1> ) < Len( <cString2> ) |
| The function returns when the last character of <cString1> is processed. |
| See also: | AddASCII(), CharAND(), CharOR(), CharSub(), CharXOR() |
| Category: | CT:String manipulation , Character functions |
| Source: | ct\charop.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The function displays results of CharAdd()
PROCEDURE Main
LOCAL cString := "ABC"
? CharAdd( cString, Chr(3) ) // result: DEF
? CharAdd( cString, Space(3) ) // result: abc
RETURN
http://www.xHarbour.com