CHARSUB()
Subtracts corresponding ASCII value of two strings
Syntax
CHARSUB( <[@]cString1>, <cString2>) --> cSubString
Arguments
<[@]cString1> first string <cString2> second string
Returns
<cSubString> string with subtracted ASCII values
Description
The CHARSUB() function constructs a new string from the two strings passed as parameters. To do this, it subtracts the ASCII values of the corresponding characters of both strings and places a character in the resulting string whose ASCII value equals to that difference (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
? charsub( "012345678", Chr( 1 ) ) // --> "/01234567" ? charsub( "123456789", Chr( 255 ) ) // --> "23456789:" ? charsub( "9999", Chr( 0 ) + Chr( 1 ) + Chr( 2 ) + Chr( 3 ) ) // --> "9876"
Tests
charsub( "123456789", Chr( 1 ) ) == "012345678" charsub( "123456789", Chr( 1 ) + Chr( 2 ) ) == "002244668" charsub( "012345678", Chr( 255 ) ) == "123456789" charsub( "012345678", Chr( 255 ) + Chr( 254 ) ) == "133557799"
Compliance
CHARSUB() is a new function that is only available in Harbour’s CT3 lib.
Platforms
All
Files
Source is charop.c, library is ct3.
Seealso
CHARADD(), CHARAND(), CHARNOT(), CHAROR(), CHARXOR(), CHARSHL(), CHARSHR(), CHARRLL(), CHARRLR(), CSETREF()
Pingback: Harbour String Functions | Viva Clipper !
Pingback: Harbour All Functions – C | Viva Clipper !