----------------------------I am trying to remove all double spaces in text in 
order to replace the remaining single spaces with a comma so that I can use 
SSUB on the converted string.

The target string (vVarData) may have an unknown number of spaces between the 
words. There's no pattern from one string to another. In theory there's no 
limit to the length of any space although, in practice, it's likely only to be 
a few space "characters".

I expected to be able to come up with something rather more eloquent than this:

SET VAR vVarData = (TRIM(.vVarData))
LABEL lSpaces
  SET VAR vCount = 0
  SET VAR vCount = (SLOC(.vVarData, '  '))
  IF vCount <> 0 THEN
    SET VAR vVarData = (SRPL(.vVarData, '  ', ' ', 0))
    GOTO lSpaces
    ENDIF
SET VAR vVarData = (SRPL(.vVarData, ' ', ',', 0))
SET VAR vWord3 = (SSUB(.vVarData, 3))
SET VAR vWord4 = (SSUB(.vVarData, 4))
SET VAR vWord6 = (SSUB(.vVarData, 6))

Am I missing a more obvious method to get the end result?

Regards, 

Alastair 

 

----------------------------

Alastair Burr

St. Albans, UK.

[EMAIL PROTECTED]

-----------------------------

 

Reply via email to