06-24-2016 05:40 PM
There may be easier ways.
It may be that this is not what you really want. Remember, you are only shifting text over since the length of a character variable is fixed.
You may be better served by the COMPBL function.
WIth all that in mind, here is a way to approach what you asked for:
if string > ' ' then do i=1 to length(string) until (blanks=2);
if substr(string, i, 1)=' ' then blanks + 1;
if blanks=2 then string = substr(string, 1, i-1) || substr(string, i+1);
I also tried looking at CALL SCAN, but didn't find an approach that seemed like it would work.
06-24-2016 11:27 PM
Given the string
where s is a space, do you want
AsBCssD (second space of the string removed)
AsBsCsD (double space replaced by single space) ?
06-25-2016 12:36 AM
What does "2nd space" mean? The 2nd occurence of a space or just don't have consecutive spaces?
For "not consecutive spaces" I'd use function "compbl()"
Need further help from the community? Please ask a new question.