xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

NumToken()

Returns the number of tokens in a string.

Syntax

NumToken( <cString>    , ;
         [<cDelimiter>], ;
         [<nSkipWidth>]  ) --> nCount

Arguments

<cString>
This is a character string to count tokens in.
<cDelimiter>
This character string holds a list of characters recognized as delimiters between tokens. The default list of delimiters consist of non-printable characters having the ASCII codes 0, 9, 10, 13, 26, 32, 138 and 141 and the following punctuation characters: ,.;:!?/\<>()#&%+-*
<nSkipWidth>
This optional numeric value defaults to zero. This causes the function to count empty tokens. To suppress this behavior, set <nSkipWidth> to 1.

Return

The function returns the number of tokens found in a string as a numeric value

Info

See also:AtToken(), Token(), TokenLower(), TokenUpper()
Category: CT:String manipulation , Character functions , Token functions
Source:ct\token1.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays the number of tokens using different delimiters

   PROCEDURE Main
      LOCAL cDate := DtoC( StoD( "20061231" ) )
      LOCAL cTime := Time()
      LOCAL cFile := CurDrive()+ ":\" + CurDir() + "\Test.prg"

      ? NumToken( cDate, "/." )                // result: 3

      ? NumToken( cTime, ":"  )                // result: 3

      ? NumToken( cFile, ":\."  )              // result: 6
   RETURN

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