Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
STRTRANS and Slashes
Message
 
 
À
10/12/2007 19:09:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01274617
Message ID:
01274656
Vues:
12
>>I need to make sure that there are two slashes only in a textbox value. It usually would start with only 1 slash, so it would be increased to two, but over time it was replacing the doubles with 4, etc. This code in the LostFocus seems to work, but I know it's not the best way. Any ideas? Thanks!
>>
>>
>>THISFORM.DataDir = STRTRAN(THIS.Value,'\','\\')
>>THISFORM.DataDir = STRTRAN(THIS.Value,'\\\','\\')
>>
>Could you use the Foxtools REDUCE() function????
>&& Step by Step
>lcTemp = THIS.value
>lcTemp = CHRTRAN(lcTemp," ",CHR(255))  && Keep all the current spaces
>lcTemp = REDUCE(lcTemp,"\")  && Convert all contiguous \ to space
>lcTemp = STRTRAN(lcTemp," ","\\")  && Convert space to \\
>lcTemp = CHRTRAN(lcTemp,CHR(255)," ")  && Restore the spaces
>
>
>
>Thisform.DataDir = CHRTRAN(STRTRAN(REDUCE(CHRTRAN(this.value," ",CHR(255)),"\")," ","\\"),CHR(255)," ")
I was actually also thinking about reduce, but without having VFP on this PC I can only try in my mind and it was not enough to create the full solution.
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform