Alastair,

My favorite command language REXX has a marvelous function:
SPACE(string,n,pad)
Formats the blank-delimited words in "string" with n "pad:
characters between each word.

for example SET VAR vTval = 'aa   bb  cc dd'
set var vcln = (SPACE(.vTval,1,' '))
show var vcln
'aa bb cc dd'  

Jim Bentley

--- Alastair Burr <[EMAIL PROTECTED]> wrote:

> ----------------------------I don't know why this appeared for
> a second time - I didn't re-send it intentionally - so
> apologies all round.
> 
> However, it gives me the opportunity to reply to Ben, Mike &
> Larry:
> 
> Thanks for your responses.
> 
> I prefer the while loop to my goto so that's an improvement -
> thanks Ben & Larry.
> 
> I looked at the SSTRIP(I) functions when I was searching for a
> function that I was sure must exist to do what I wanted. I
> concluded that I could take out all the spaces but that
> wouldn't leave me a way to use SSUB. Thanks Mike, if I'm
> missing a way to do what I want with it please let me know.
> 
> I had already discovered the problem with SLOC and double
> spaces after I posted originally and before Larry's comments.
> I'd got around it by replacing all spaces with a | and then
> getting rid of the double ones - much as suggested.
> 
> It seems obvious to ask why SLOC has a problem identifying two
> spaces? Is it an R:Base problem or a Windows/general computing
> one? IF it's an R:Base one does it need reporting or is RBTI
> aware already?
> 
> Also, is there a need for a function that can take out the
> words from a string regardless of the number of spaces between
> them? A sort of "Super-SLOC" that, perhaps, works on any
> number of spaces rather than the comma (or whatever the
> delimit is set to)?
> 
> Regards,
> Alastair.
> 
> 
>   ----- Original Message ----- 
>   From: Alastair Burr 
>   To: RBASE-L Mailing List 
>   Sent: Saturday, May 03, 2008 8:31 AM
>   Subject: [RBASE-L] - Removing multiple spaces from a string
> 
> 
>   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]
> 
>   -----------------------------
> 
>    
> 
> 
> 
>
------------------------------------------------------------------------------
> 
> 
>   No virus found in this incoming message.
>   Checked by AVG. 
>   Version: 7.5.524 / Virus Database: 269.23.8/1412 - Release
> Date: 02/05/2008 16:34
> 


Jim Bentley
American Celiac Society
[EMAIL PROTECTED]
tel: 1-504-737-3293


      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


Reply via email to