xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CtoBit()

Converts a character string to an integer based on a bit pattern.

Syntax

CtoBit( <cString> , <cBitPattern> ) --> nInteger

Arguments

<cString>
This is a character string to be traversed.
<cBitPattern>
This is a character string defining the bit pattern. It may contain a maximum of 16 characters. If a character of <cBitPattern> is found in <cString>, the bit at the corresponding position of the return value is set to 1.

Return

The function returns an integer value in the range of 0 to 65535.

Info

See also:BitToC(), NtoC()
Category: CT:NumBits , Numbers and Bits
Source:ct\numconv.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays results of CToBit() along with their
// binary representation.

   PROCEDURE Main

      ? n := CToBit( "C", "ABCD" )     // result: 2
      ? NtoC( n, 2, 4, "0" )           // result: 0010

      ? n := CToBit( "ACD", "ABCD" )   // result: 11
      ? NtoC( n, 2, 4, "0" )           // result: 1101
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe