Converts position-dependent bits into characters


               --> <cBitString>


<nInteger> Designates a number in the range of 0 to 65535, which corresponds to a bit pattern.

<cBitpattern> Designates a character string with a maximum of 16 characters. Each character corresponds to a bit in <nInteger>, where the last character corresponds to the lowest-value bit.

<lMode> When this optional parameter is designated as .T., 0 bits change to blanks. The default is no change.


The returned string contains the corresponding characters passed by the bit pattern.


The BITTOC() function changes the bits of a number into a sequence of corresponding characters. This facilitates work with such bit-coded information as file attributes. Depending on the <lMode> logical parameter (the l in lMode symbolizes logical), 0 bits either displays no character (.F.) or a blank (.T.).


. If <lMode> is designated as .T., the string length that results always corresponds to <cBitpattern>.


       .  Change file attributes:
           .  The number 2 corresponds to a binary "00000010":
              ? BITTOC(2, "ADVSHR")            // "H" as the next to
                                               // last character
           .  The number 5 corresponds to a binary "00000101":
              ? BITTOC(5, "ADVSHR")            // "SR"
           .  The number 5, with the 0 bit displayed as a blank:
              ? BITTOC(5, "ADVSHR", .T.)       // "   S R"


Source is numconv.prg, library is libct.

See also



2 responses to “BitToC()

  1. Pingback: Harbour Conversion Functions | Viva Clipper !

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

Leave a Reply

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

You are commenting using your 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.