xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CountLeft()

Counts a specified character from the left side of a string.

Syntax

CountLeft( <cString>, [<xChar>] ) --> nCount

Arguments

<cString>
This is the character string to process.
<xChar>
A single character or its numeric ASCII code can be passed. The default value is a space character (Chr(32)).

Return

The function counts <xChar> at the beginning of <cString> and returns as soon as a different character is detected. The number of times the character <xChar> is found consecutively at the beginning of <cString> is returned as a numeric value.

Info

See also:CountRight(), LTrim()
Category: CT:String manipulation , Character functions
Source:ct\count.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays results of CountLeft()

   PROCEDURE Main
       LOCAL cString1 := "   Hello World "
       LOCAL cString2 := "aaaaabbbbbcc"

       ? CountLeft( cString1 )        // result: 3
       ? CountLeft( cString2, "a" )   // result: 5

   RETURN

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