BitToC()

BitToC()

Converts position-dependent bits into characters

Syntax

       BITTOC(<nInteger>,<cBitpattern>,[<lMode>])
               --> <cBitString>

Arguments

<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.

Returns

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

Description

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.).

Note

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

Examples

       .  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"

Files

Source is numconv.prg, library is libct.

See also

CTOBIT() CTON()

Advertisements

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:

WordPress.com Logo

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

Google+ photo

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

Connecting to %s