CharAnd()

CHARAND()

Combine corresponding ASCII value of two strings with bitwise AND

Syntax

      CHARAND( <[@]cString1>, <cString2> ) --> cAndString

Arguments

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

Returns

<cAndString> string with bitwise AND combined ASCII values

Description

The CHARAND() function constructs a new string from the two strings passed as parameters. To do this, it combines the ASCII values of the corresponding characters of both strings with a bitwise AND-operation and places a character in the resulting string whose ASCII value equals to the result of that operation. 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

      // clear the LSB
      ? charand( "012345678", chr( 254 ) ) // --> "002244668"
      ? charand( "012345678", chr( 254 ) + chr( 252 ) ) // --> "002044648"

Tests

      charand( "012345678", chr( 254 ) ) == "002244668"
      charand( "012345678", chr( 254 ) + chr( 252 ) ) == "002044648"

Compliance

CHARAND() is compatible with CT3’s CHARAND().

Platforms

All

Files

Source is charop.c, library is ct3.

Seealso

CHARADD(), CHARSUB(), CHARNOT(), CHAROR(), CHARXOR(), CHARSHL(), CHARSHR(), CHARRLL(), CHARRLR(), CSETREF()

2 responses to “CharAnd()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – C | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.