|
Hi Jeff,The parms for %replace are: replacement string, source string, start position, length. The %scan you have will find the comma in position 2, but you add 1 to that, so the length parm in your %replace is actually 3, i.e.
ChrOut = %replace ('':ChrIN:1:3)which will replace positions 1-3 of ChrIN with a zero-length string, which leaves you with 00.70, which is what you got.
Another point about %replace is that it only does one replacement. If there were more than one comma in ChrIn, it would only replace the first one.
If you had reversed the 3rd & 4th parms of your %replace, you'd've run into another problem -- ChrOut is too small to hold the result. "1,100.70" is 8 characters. Remove the comma and you have 7 characters, but ChrOut is only 5. Better make it the same as ChrIn in case there are no commas in ChrIn.
So what you probably want is something like: D CHRIn s 17a INZ('1,100.70') D CHROut s 17a D x s 5i 0 /free dow ChrIn <> 'QUIT'; dou x = *zero; x = %scan(',' : ChrOut); if x > *zero; ChrOut = %replace('' : ChrOut : x : 1); endif; enddo; DSPLY ChrOUT ' ' ChrIN; EndDo; *INLR = *On; /end-free *Peter Dow* / Dow Software Services, Inc. 909 793-9050 pdow@xxxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxxx> / jstevens@xxxxxxxxxxxxxx wrote:
I'm trying to remove the commas in a field using the folling code... D CHRIn s 17a INZ('1,100.70') D CHROut s 5a /free DoW ChrIn <> 'QUIT'; ChrOut = %replace('':ChrIN:1:%scan(',':ChrIN)+1 ); DSPLY ChrOUT ' ' ChrIN; EndDo; *INLR = *On;/end-freeAnd it Produces the following result...DSPLY 00.70 1,100.70But I want it to produce DSPLY 1100.70 1,100.70 Can anyone see where I'm going wrong? Thanks! Jeff Stevens Mize, Houser & Co. P.A. 913 451 1882 JStevens@xxxxxxxxxxxxxx
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.