Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
String differences
Message
 
À
21/05/2010 09:35:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01465324
Message ID:
01465494
Vues:
48
>>Is there a function that indicates which chars differ between 2 strings?
>
>
>s1='abcde'
>
>s2='abCde1'
>
>
>? "native version",StringDifference(m.s1,m.s2)
>
>? "text version",CAST(CHRTRAN(StringDifference(m.s1,m.s2),0h00FF,'=#') AS M)
>
>? "match chars on first string",StringGetMatch(m.s1,m.s2)
>
>* simple to do other functions
>
>FUNCTION StringDifference(s1,s2)
>* return a binary pattern: 00 match, FF unmatch
>LOCAL sDiffMask
>sDiffMask = BITXOR(CAST(m.s1 AS W),CAST(m.s2 AS W))
>RETURN BITOR(BITNOT(CHRTRAN(m.sDiffMask ,0h0,0hFF)),m.sDiffMask)
>
>FUNCTION StringGetMatch(s1,s2)
>RETURN CAST(CHRTRAN(BITAND(BITNOT(StringDifference(@m.s1,@m.s2)),CAST(m.s1 AS W)),0H0," ") AS M)
>
Getting complicated here, my ver 8 is crying foul with the cast statement :-(
"Build a man a fire, and he's warm for a day.
Set a man on fire, and he's warm for the rest of his life."
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform