Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing repetitive spaces from strings
Message
 
À
13/05/1997 22:46:39
Larry Long
ProgRes (Programming Resources)
Georgie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00032009
Message ID:
00032297
Vues:
41
>>Yes, I know, but I was hoping that there was a function to do this already. Thanks anyway for your time and code.
>Take a look at the STRTRAN() function

That is eventually what I ended up using. Unfortunately, I had to call STRTRAN() in a loop to remove all repetitve spaces. If anyone knows of a Windows API call to do this, I would be very interested to hear about it.

By the way, here is the code that I used:

LPARAMETERS tcString
LOCAL lcRetVal
LOCAL lnNewLen, lnOldLen

lcRetVal = ALLTRIM(tcString) && Remove leading a trailing spaces
lnNewLen = LEN(lcRetVal) && Length of string
lnOldLen = lnNewLen + 1 && Make sure that loop is done at least once

DO WHILE lnNewLen < lnOldLen && While more repetitive spaces exist...
lnOldLen = lnNewLen && Length before removal of spaces
lcRetVal = STRTRAN(lcRetVal, SPACE(2), SPACE(1))
&& Remove repetitive spaces
lnNewLen = LEN(lcRetVal) && Length after removal of spaces
ENDDO

RETURN lcRetVal

Thanks anyway!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform