FT_AT2() Find position of the nth occurrence of a substring FT_BITCLR() Clear (reset) selected bit in a byte FT_BITSET() Set selected bit in a byte FT_BYTEAND() Perform bit-wise AND on two ASCII characters (bytes) FT_BYTENEG() Perform bit-wise negation on an ASCII character FT_BYTENOT() Perform bit-wise NOT on an ASCII character (byte) FT_BYTEOR() Perform bit-wise OR on two ASCII characters (bytes) FT_BYTEXOR() Perform bit-wise XOR on two ASCII characters (bytes) FT_FINDITH() Find the "ith" occurrence of a substring within a string FT_ISBIT() Test the status of an individual bit FT_ISBITON() Determine the state of individual bits in a number FT_METAPH() Convert a character string to MetaPhone format FT_NOOCCUR() Find the number of times one string occurs in another FT_PCHR() Convert printer control codes FT_PROPER() Convert a string to proper-name case
Tag Archives: FT_BITSET()
FT_ISBITON
FT_ISBITON() Determine the state of individual bits in a number Syntax FT_ISBITON( <nNumber>, <nBit> ) -> lResult Arguments <nNumber> is an integer for which a bit state needs to be checked. <nBit> is a number from 0 to 15 that indicates which bit to test. Returns .T. if the specified bit was on., .F. if off. Description This function is useful when dealing with binary integers. It will come in very handy if you use the FT_INT86() function, because the CPU flags are returned as a series of bits. Using this function, you can determine the state of each CPU flag. Examples if FT_ISBITON( nCPUFlags, 0 ) Qout( "The carry flag was set." ) endif if FT_ISBITON( nCPUFlags, 7 ) Qout( "The sign flag was set." ) endif Source: ISBITON.PRG Author: Ted Means
FT_ISBIT
FT_ISBIT() Test the status of an individual bit Syntax FT_ISBIT( <cByte>, <nBitPos> ) -> lResult Arguments <cByte> is a character from CHR(0) to CHR(255) <nBitPos> is a number from 0 to 7 conforming to standard right-to-left bit-numbering convention and representing the position of the bit within the byte. Returns .T. if designated bit is set (1), .F. if not set (0), NIL if invalid parameters. Description Tests for status of any selected bit in the byte passed as a parameter. Byte must be presented in CHR() form, as a literal constant, or as the one-byte character result of an expression. This function is presented to illustrate that bit-wise operations are possible with Clipper code. For greater speed, write .C or .ASM versions and use the Clipper Extend system. Examples This code tests whether bit 3 is set in the byte represented by CHR(107): lBitflag := FT_ISBIT(CHR(107), 3) ? lBitflag // result: .T. This code tests whether bit 5 is set in the byte represented by ASCII 65 (letter 'A') ? FT_ISBIT('A', 5) // result: .F. For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code. Source: ISBIT.PRG Author: Forest Belt, Computer Diagnostic Services, Inc.
See Also: FT_BITSET() FT_BITCLR()
FT_BITSET
FT_BITSET() Set selected bit in a byte Syntax FT_BITSET( <cByte>, <nBitPos> ) -> cByte Arguments <cByte> is a character from CHR(0) to CHR(255). <nBitPos> is a number from 0 to 7 conforming to standard right-to-left bit numbering convention and representing the position of the bit within the byte. Returns Returns new byte, with designated bit set. If parameters are faulty, returns NIL. Description In effect, ORs argument byte with a byte that has only the target bit set. If bit is already set, it remains set. Note: Calls FT_ISBIT() which is also in this Library. This function is presented to illustrate that bit-wise operations are possible with Clipper code. For greater speed, write .C or .ASM versions and use the Clipper Extend system. Examples This code would set bit 4 in a byte represented by CHR(107): cNewbyte := FT_BITSET( CHR(107), 4 ) ? ASC( cNewbyte ) // result: 123 ? cNewbyte // result: '{' This code would set bit 5 in the byte represented by the letter 'A'. ? FT_BITSET( 'A', 5 ) // result: 'a' // bit 5 set For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code. Source: BITSET.PRG Author: Forest Belt, Computer Diagnostic Services, Inc.
See Also: FT_BITCLR() FT_ISBIT()
FT_BITCLR
FT_BITCLR() Clear (reset) selected bit in a byte Syntax FT_BITCLR( <cByte>, <nBitPos> ) -> cByte Arguments <cByte> is a character from CHR(0) to CHR(255). <nBitPos> is a number from 0 to 7 conforming to standard right-to-left bit numbering convention and representing the position of the bit within the byte. Returns Returns new byte, with designated bit cleared (reset). If parameters are faulty, returns NIL. Description In effect, ANDs argument byte with a byte that has all bits set except the target bit. If bit is already clear (0), it remains clear. Note: Calls FT_ISBIT() which is also in this Library. This function is presented to illustrate that bit-wise operations are possible with Clipper code. For greater speed, write .C or .ASM versions and use the Clipper Extend system. Examples This code would clear bit 4 in a byte represented by CHR(115): cNewByte := FT_BITCLR( CHR(115), 4 ) ? ASC( cNewbyte ) // result: 99 ? cNewByte // result: 'c' This code would clear bit 5 in the byte represented by letter 'A': FT_BITCLR( 'A', 5 ) // result: 'A', since // bit 5 already clear For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code. Source: BITCLR.PRG Author: Forest Belt, Computer Diagnostic Services, Inc.
See Also: FT_BITSET() FT_ISBIT()