CToBit()

CToBit()

Converts a character string into a bit pattern

Syntax

       CToBit( <ccCharacterstring>, <cBitPattern> ) -> <nWord>

Arguments

<cCharacterstring> Designates a character sequence. When this sequence occurs in the second character string, each corresponding bit is set to 1.

<cBitpattern> Designates a sequence, with a maximum of 16 characters, from which the bit position is assigned.

Returns

CToBit() returns a number in the range of 0 to 65535 that corresponds to the created bit pattern.

Description

The CToBit() function delivers a bit pattern that corresponds to a string of individual characters. When used in conjunction with its sister function BitToC(), it facilitates work with such bit-coded information as file attributes.

Note

. Characters in <cCharacterstring> that are not found in <cBitpattern> are ignored.

Examples

       .  The second bit in the resulting value is set, since the letter
              "H" appears in the next-to-last position in "ADVSHR":
              ? CToBit("H", "ADVSHR")          // Result:  00000010
           .  Two characters also in ADVSHR, appear at the first and final
              positions in this 6-character string:
              ? CToBit("RA", "ADVSHR")         // Result:  00100001
           .  <cBitpattern> ignores previously unavailable characters:
              ? CToBit("XRYA", "ADVSHR")       // Result:  00100001

Platforms

All

Files

Source is numconv.prg, library is libct.

Seealso

BitToC()

2 responses to “CToBit()

  1. Pingback: Harbour Conversion 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.