Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parsing Strings
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00389092
Message ID:
00389098
Vues:
23
>Is there a SPLIT function like VB has to parse a string by a delimiter passed to the function and return an array? I can certainly write my own but it seems there should be one already avaliable just can't put my finger on it.
>
>Thanks in advance.
>
Tommy,

You'll have to sorta roll you own. I say "sorta" because foxtools has two functions (Words() and WordNum()) that can help simplify the process. The following example demonstrates. It assumes that Foxtools is already loaded
FUNCTION VFPSplit
  LPARAMETERS tcString, tcDelimeters, taArray

  EXTERNAL ARRAY taArray
  LOCAL lni, lnlast
  lnlast = Words(tcString, tcDelimeters)
  IF lnlast > 0
    DIMENSION taArray[lnlast]
    FOR lni = 1 TO lnlast
      taArray[lni] = WordNum(tcString, lni, tcDelimeters)
    NEXT
  ENDIF
  RETURN lnlast
ENDFUNC
In the example above, the array must be passed by reference.
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform