>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