Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP code syntax coloring in HTML
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00355687
Message ID:
00361266
Vues:
45
George,

Thanks for this suggestion. I'm thinking about several additional #define at the top of my program and also local variables in aparser. That's a good point.

BTW, now it runs in ~0.1 sec.

Regarding FoxTools. Previously we (our development team) used this function to parse the string:
*!******************************************************************************
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" $ upper(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
While ago somebody asked an algorithm to parse a string and I post this program.
Cetin Basoz explained to me, that this program is unefficient for long strings and sent me his own .fll (list2array - if I remember correctly). Somebody else post an idea of using alines(), which I also like. I made several tests on really long strings and found, that alines() approach and Cetin's fll works 100 times faster, than FoxTools. Since then I prefer either of these two approaches.

If you can find this thread, it would be great. (It was ~ 11-12 months ago)

Thanks again.

>Nadya (and Mike),
>
>From what I gather from the code (and from other threads on this subject) one of the things you're trying to accomplish here is to speed up the routine. One thing that catches my eye is the calling (unnecessarily) of some functions. For example, a number times the CHR(13) + CHR(10) is called. Assign the characters to a variable, and reference the variable instead. The same applies to CHR(13), SPACE(1), CHR(254). Each time you reference the function you incur additional processing overhead. When you assign them to variables, you incur this only once.
>
>You also might want to look at the Foxtools functions Words() and WordNum() for parsing the strings.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform