Two more Clipper Tools Functions replace with pure Clipper 
Author Message
 Two more Clipper Tools Functions replace with pure Clipper

Here is NUMTOKEN() and TOKEN(), two very handy functions from Clipper
Tools III which you can now replace with the pure Clipper replacement.

We all know that CTIII has problems with protected mode. This is
another step to end it's use in my programs, and I thought you'd like
it, too.

#include 'common.ch'

function token( cString, cDelimiter, nPointer )

local x
local nStrLen        := len( cString )
local nHowMany       := 0
local nLastPointer   := 0
local cPart
local lFoundWord     := .f.

default cDelimiter to ' ,.;:!?/\<>()^#&%+-*' + chr( 0 ) + chr( 9 ) + ;
        chr( 10 ) + chr( 13 ) + ;
        chr( 26 ) + chr( 138 ) + ;
        chr( 141 )

default nPointer to -1

for x := 1 to nStrLen
   if substr( cString, x, 1 ) $ cDelimiter
      if lFoundWord
         nHowMany ++
      endif
      if nHowMany == nPointer
         exit
      endif
      do while x < nStrLen .and. ;
                    substr( cString, x + 1, 1 ) $ cDelimiter
         x ++
      enddo
      nLastPointer  := x
   else
      lFoundWord    := .t.
   endif
next

if x == nStrLen + 1   // went all the way without nHowmany == nPointer
   // take the last word
   cPart := substr( cString, nLastPointer + 1 )
else
   cPart := substr( cString, ;
                            nLastPointer + 1, ;
                            ( x - nLastPointer ) - 1 )
endif

return cPart

------------------------

function numtoken( cString, cDelimiter )

local x
local nStrLen        := len( cString )
local nHowMany       := 0
local lFoundWord     := .f.
local retval         := 0

default cDelimiter to ' ,.;:!?/\<>()^#&%+-*' + chr( 0 ) + chr( 9 ) + ;
        chr( 10 ) + chr( 13 ) + ;
        chr( 26 ) + chr( 138 ) + ;
        chr( 141 )

for x := 1 to nStrLen
   if substr( cString, x, 1 ) $ cDelimiter
      if lFoundWord
         nHowMany ++
      endif
      do while x < nStrLen .and. ;
                    substr( cString, x + 1, 1 ) $ cDelimiter
         x ++
      enddo
   else
      lFoundWord    := .t.
   endif
next

if nStrLen > 0
   retval := iif( right( cString, 1 ) $ cDelimiter, ;
                                nHowmany, nHowMany + 1 )
endif

return retval

---


                       WWW   http://www.*-*-*.com/ ~philb/
                  FTP Site  ftp://ftp.iag.net/pub/clipper

  Obstacles are things a person sees when they takes their eyes off their goal



Wed, 07 Jul 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. clipper tools Clipper 5.3

2. Clipper 5.2e, Clipper Tools and Novell 5 ???

3. Clipper Tools and Clipper 5.2 upgrade

4. clipper 5.2 + Clipper Tools + PII 300 Mhz = PROBLEMS

5. Forms Designer, RAD or CASE Tool Need for Clipper prefer Clipper S87

6. Clipper, Clipper Tools, Netware and NT4

7. Clipper Tools 3.0 and Clipper 5.3

8. Clipper 5.3 and Clipper Tools

9. clipper 5.3 & clipper tools v 3.00

10. Eten Chinese System 3.52, Clipper 5.2e, Exospace 1.0g, Clipper Tools 3.0b Problem

11. CA-Clipper 5.3 with CA-Clipper Tools

 

 
Powered by phpBB® Forum Software