Converts position-dependent bits into characters
BITTOC(<nInteger>,<cBitpattern>,[<lMode>]) --> <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.