Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I split strings with | in them?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00214427
Message ID:
00214515
Vues:
17
>Hi Erik!
>
>>>Meel, dhr. H.J. van|Posthumus, dhr. B.J.
>
>>OriginalString = "Meel, dhr. H.J. van|Posthumus, dhr. B.J."
>>LeftPortion = LEFT(x, ATC("|", x)-1)
>>RightPortion = SUBSTR(x, ATC("|", x)+1)
>
>Thanks alot for the answer! It works (didn't know the ATC() command :-))!! But. With textstrings which have the | in them it works fine. In my table it doesn't seem to work. I seems to be a RETURN code or something. Because if I type ?table.fieldname in the commandprompt it will show:
>
>Meel, dhr. H.J. van
>Posthumus, dhr. B.J.
>
>Instead of the | sign. Because if I make a variable like:
>
>OriginalString = "Meel, dhr. H.J. van|Posthumus, dhr. B.J."
>
>And then ?Originalstring then I get a nice print of:
>
>Meel, dhr. H.J. van|Posthumus, dhr. B.J.
>
>So in other words I need to specify the return sign somehow. In C it's /n but what is it in FoxPro?
>
>Thanks!
Hi Michel,

PMFJI, but it's probably CHR(13). Another way to do this is to use the Foxtools functions Words() and WordNum() with a technique similar to:
* Get the number of sub-strings
lnlast = Words(OriginalString, CHR(13))
FOR lni = 1 TO lnlast
  lcsubstring = WordNum(OriginalString, CHR(13))
  * Do whatever you need
NEXT
Of course, don't forget to SET LIBRARY TO FOXTOOLS, prior to trying the above.

hth,
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