Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing repetitive spaces from strings
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00032009
Message ID:
00032017
Vues:
33
>Does the FoxTool function Reduce (or a similar function) exist in the Windows API? I need to remove repetitive spaces from a string. Below is the functions specifications from the FoxTools:
>
>REDUCE(, )
>Returns: Character
>Description: Removes repetitive values in a string. Usually used to remove
> groups of spaces in a string and replace it with one space.
> - Character string to change
> - Characters to search for
>Example: ? REDUCE("This is lots of spaces", " ")
> (returns: This is lots of spaces)
> ? REDUCE("Repeat characters AAAA and delete", "A")
> (returns: Repe t ch r cters nd delete)
>
>Thanks!

It takes few minutes to write this function in VFP:
function reduce
lparameter cString,cChar
local cNewstring,nLength,nLoop,nRepeat
cNewstring=""
nLength=len(cString)
nRepeat=0
for nLoop=1 to nLength
if substr(cString,nLoop,1)==cChar
nRepeat=nRepeat+1
if nRepeat=1
cNewstring=cNewstring+substr(cString,nLoop,1)
endif
else
nRepeat=0
cNewstring=cNewstring+substr(cString,nLoop,1)
endif
endfor
return cNewstring
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform