Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extract a Word
Message
 
 
To
11/07/2001 15:23:28
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00529297
Message ID:
00529425
Views:
12
>Thanks again; this will help when I upgrade to VFP 7.
>
>Hilmar.
>
>>Not all. These particular functions have been moved as of VFP 7 as GetWordCount and GetWordNum, respectively.
*!******************************************************************************
function aparser1
*  Description.......: Function parses a text string into an array.
*                    : Each element of the array contains one word...
*  Calling Samples...: dimension laWords[1]
*                    : lcWordString = "Some text string"
*                    : lnWords = aparser1(@laWords, lcWordString)
*  Parameter List....: taWords, tcWordString, tcDelimiter
********************************************************************
lparameter taWords, tcWordString, tcDelimiter
local lnWords, lni
external array taWords
if vartype(m.tcWordString)<>"C"
   return .f. && First and second parameters are required
endif
if vartype(m.tcDelimiter)<>'C'
     tcDelimiter=space(1) && Default delimiter
endif
* Idea of Charlie Schreiner  #011905
*!* Now put each element in an array.
lnWords=alines(taWords, strtran(m.tcWordString, m.tcDelimiter, chr(13)))
return m.lnWords
*!******************************************************************************
FUNCTION aparser
     *  Description.......: Function parses a text string into an array.  
     *                    : Each element of the array contains one word...
     *  Calling Samples...: dimension laWords[1]
     *                    : lcWordString = "Some text string"
     *                    : lnWords = aparser(@laWords, lcWordString)
     *  Parameter List....: paWords, pcWordString, pcDelimiter
     ********************************************************************
     lparameter paWords, pcWordString, pcDelimiter
     local lnWords, lni
     external array paWords

     if not "FOXTOOLS.FLL" $ set("library")
          set library to foxtools.fll additive
     endif

     pcDelimiter = iif(empty(pcDelimiter), space(1), pcDelimiter)

     lnWords = Words(pcWordString, pcDelimiter)

    IF lnWords>0 && Not empty string 
          dimension paWords[lnWords]

          for lni = 1 to lnWords
               paWords[lni] = WordNum(pcWordString, lni, pcDelimiter) && Array of words
          endfor
     ELSE
         dimension paWords[1] && For empty string lnWords=0
         paWords[1]=""
     ENDIF         
     return lnWords
And another approach would be to use fll written by Cetin Basoz. Ask him about it...
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform