|
I'd rather use a check for ' ' then use %replace on the non-blanks or spin through that puppy with a DO While (for next anyone) and perform a %replace on the string.. so like this.. c For x=1 to %Len(%Trim(string)) c Select c When %Subst(string:x:1) <> '_' and FirstSpace * Reset First Space for next block of alpha's c Eval Firstspace = *On c iter c When %Subst(string:x:1) = '_' and FirstSpace * Set FirstSpace and skip the first one to make sure you still have one space between text c Eval Firstspace = *Off c iter c When %Subst(string:x:1) = '_' and not FirstSpace * Replace it out with NOTHING (compress...) c Eval Stinin = %replace(' ':String:x:1) c iter c endsl c endfor Replace the '_' with a space - it just didn't look good while entering... Andrew Borts / Webmaster Seta Corporation 6400 East Rogers Circle Boca Raton, FL 33499 E-mail: Andrewb@setacorporation.com Corporate web site http://www.setacorporation.com E-Commerce web site http://www.palmbeachjewelry.com http://www.myfreeitems.com Voice: 561-994-2660 Ext. 2211 / Fax: 561-997-0774 -----Original Message----- From: Amitava Banerjee [mailto:Amitava.Banerjee@trin.net] Sent: Tuesday, January 22, 2002 2:48 PM To: rpg400-l@midrange.com Subject: Removing a dash from a phone number Suppose the field name for your phone number is OLDPH, then the code might be like this Z-ADD 1 I 10 MOVE *BLANKS NEWPH 8 I DOWLE 8 1 SUBST OLDPH:I CH 1 CH IFNE '-' NEWPH CAT CH:0 NEWPH ENDIF ADD 1 I ENDDO In ILE it will be D pos s 1s 0 inz(1) D newph s 8a inz(*blanks) D oldph s 8a inz('123-4567') D ch s 1a inz(*blanks) C DOW POS <= 8 C EVAL CH = %SUBST(OLDPH:POS:1) C IF ch <> '-' C newph CAT ch:0 newph C endif C eval pos = pos + 1 C enddo Hope it helps. Amitava _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.