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_FINDITH

FT_FINDITH()
 Find the "ith" occurrence of a substring within a string

 Syntax

      FT_FINDITH( <cCheckFor>, <cCheckIn>, <nWhichOccurrence> ;
                  [, <lIgnoreCase> ] ) -> <nStringPosition>

 Arguments

     <cCheckFor> is the string to search for.

     <cCheckIn> is the string to search.

     <nWhichOccurrence> is the number of the occurrence to find.

     <lIgnoreCase> is a logical indicating if the search is to be case
        sensitive.  The default is no case sensitivity (.F.).

 Returns

     The position in the string cCheckIn of the ith occurrence of cCheckFor.

 Description

     This function finds the position in a string of the "ith" time another
     string appears in it.

 Examples

     // Find the Position in cMemoString of
     // the 10th Occurrence of "the", case
     // insensitive

     nNextPosition := FT_FINDITH("the", cMemoString, 10)

 Source: FINDITH.PRG

 Author: David Husnian

See Also: FT_AT2()

 

FT_BYTEXOR

FT_BYTEXOR()
 Perform bit-wise XOR on two ASCII characters (bytes)

 Syntax

      FT_BYTEXOR( <cByte1>, <cByte2> ) -> cNewByte

 Arguments

     <cByte1> and <cByte2> are characters from CHR(0) to CHR(255).
     May be passed in CHR() form, as character literals, or
     as expressions evaluating to CHR() values.

 Returns

     Returns resulting byte, in CHR() form.  If parameters are faulty,
     returns NIL.

 Description

     Can be used for bit-wise byte manipulation.  In effect, this is a
     bit-by-bit XOR operation.  Equivalent to XOR assembler instruction.

     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 performs a bit-wise XOR on two bytes represented
     by CHR(32) and CHR(55):

          cNewByte := FT_BYTEXOR( CHR(32), CHR(55) )
          ? ASC( cNewByte )     // result: 23
          ? cNewByte            // result: non-printable character

     For a demonstration of Clipper bit manipulations, compile and
     link the program BITTEST.PRG in the Nanforum Toolkit source code.

 Source: BYTEXOR.PRG

 Author: Forest Belt, Computer Diagnostic Services, Inc.

See Also: FT_BYTEOR() FT_BYTENOT() FT_BYTENEG() FT_BYTEAND()



FT_BYTEOR

FT_BYTEOR()
 Perform bit-wise OR on two ASCII characters (bytes)

 Syntax

      FT_BYTEOR( <cByte1>, <cByte2> ) -> cNewByte

 Arguments

     <cByte1> and <cByte2> are characters from CHR(0) TO CHR(255).
     May be passed in CHR() form, as character literals, or as
     expressions evaluating to CHR() values.

 Returns

     Returns resulting byte, in CHR() form.  If parameters are faulty,
     returns NIL.

 Description

     Can be used for bit-wise byte manipulation.  In effect, this is a
     bit-by-bit OR operation.  Equivalent to OR assembler instruction.

     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 performs a bit-wise OR on two bytes represented
          by CHR(20) and CHR(10):

          cNewByte := FT_BYTEOR( CHR(20), CHR(10) )
          ? ASC( cNewByte )  // result: 30
          ? cNewByte         // result: non-printable character

     For a demonstration of Clipper bit manipulations, compile and
     link the program BITTEST.PRG in the Nanforum Toolkit source code.

 Source: BYTEOR.PRG

 Author: Forest Belt, Computer Diagnostic Services, Inc.

See Also: FT_BYTEXOR() FT_BYTENOT() FT_BYTENEG() FT_BYTEAND()



FT_BYTENOT

FT_BYTENOT()
 Perform bit-wise NOT on an ASCII character (byte)
------------------------------------------------------------------------------

 Syntax

      FT_BYTENOT( <cByte> ) -> cNewByte

 Arguments

     <cByte> is a character from CHR(0) to CHR(255).
     May be passed in CHR() form, as character literal, or
     as expression evaluating to CHR() value.

 Returns

     Returns resulting byte, in CHR() form.  If parameters are faulty,
     returns NIL.

 Description

     Can be used for bitwise byte manipulation.  In effect, this is a
     bit-by-bit NOT (one's complement) operation.  Equivalent to the
     NOT assembler instruction.

     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 performs a bitwise NOT on byte represented by CHR(32):

          cNewByte := FT_BYTENOT( CHR(32) )
          ? ASC( cNewByte )     // result: 223

     For a demonstration of Clipper bit manipulations, compile and
     link the program BITTEST.PRG in the Nanforum Toolkit source code.

 Source: BYTENOT.PRG

 Author: Forest Belt, Computer Diagnostic Services, Inc.

See Also: FT_BYTEOR() FT_BYTEXOR() FT_BYTENEG() FT_BYTEAND()

FT_BYTENEG

FT_BYTENEG()
 Perform bit-wise negation on an ASCII character

 Syntax

      FT_BYTENEG( <cByte> ) -> cNewByte

 Arguments

     <cByte> is a character from CHR(0) to CHR(255).
     May be passed in CHR() form, as character literal, or
     as expression evaluating to CHR() value.

 Returns

     Returns resulting byte, in CHR() form.  If parameters are faulty,
     returns NIL.

 Description

     Can be used for bit-wise byte manipulation.  In effect, this is a
     bit-by-bit NEG (two's complement) operation.  Equivalent to NEG
     assembler instruction.

     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 performs a bit-wise NEG on byte represented by CHR(32):

          cNewByte := FT_BYTENOT(CHR(32))
          ? asc(cNewByte)                  // result: 224

     For a demonstration of Clipper bit manipulations, compile and
     link the program BITTEST.PRG in the Nanforum Toolkit source code.

 Source: BYTENEG.PRG

 Author: Forest Belt, Computer Diagnostic Services, Inc.

See Also: FT_BYTEOR() FT_BYTEXOR() FT_BYTENOT() FT_BYTEAND()

FT_BYTEAND

FT_BYTEAND()
 Perform bit-wise AND on two ASCII characters (bytes)

 Syntax

      FT_BYTEAND( <cByte1>, <cByte2> ) -> cByte

 Arguments

     <cByte1> and <cByte2> are characters from CHR(0) TO CHR(255).
     May be passed in CHR() form, as character literals, or as expressions
     evaluating to CHR() values.

 Returns

     Returns resulting byte, in CHR() form.  If parameters are faulty,
     returns NIL.

 Description

     Can be used for any bit-wise masking operation.  In effect, this is a
     bit-by-bit AND operation.  Equivalent to AND assembler instruction.

     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 mask out the high nibble (four most significant bits)
     of the byte represented by chr(123) and leave the low nibble bits as in
     the parameter byte.

          cNewbyte := FT_BYTEAND( CHR(123), CHR(15) )
          ? asc(cNewByte)  // result: 11
          ? cNewByte       // result: non-printable character

     For a demonstration of Clipper bit manipulations, compile and
     link the program BITTEST.PRG in the Nanforum Toolkit source code.

 Source: BYTEAND.PRG

 Author: Forest Belt, Computer Diagnostic Services, Inc.

See Also: FT_BYTEOR() FT_BYTEXOR() FT_BYTENOT() FT_BYTENEG()

 

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