Discussion:
How to add commas to a number
(too old to reply)
Lizette Koehler
2012-12-17 23:49:29 UTC
Permalink
List -

There does not appear to be a built-in for inserting commas into a number. So before I write something really complicated, thought I would ask here.

If my number is 123456780

I want to display it as 123,456,780

And this needs to work for any number presented.

So if my number is 12345 then I want to display it as 12,345



Thanks

Lizette

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Dave Salt
2012-12-17 23:59:27 UTC
Permalink
I forget where I got this but it does what you want:

/* REXX to add commas to a number. */
arg value
if value = "" then value = "1234567"
say "Adding commas to "value
n=value'.9'
do j=verify(n,1234567890,,verify(n,1234567890.,'M'))-4 to ,
verify(n,987654321,"M") by -3
value=insert(',',value,j)
end
say 'Value =' value


Dave Salt

SimpList(tm) - try it; you'll get it!

http://www.mackinney.com/products/program-development/simplist.html
Date: Mon, 17 Dec 2012 16:48:44 -0700
Subject: How to add commas to a number
List -
There does not appear to be a built-in for inserting commas into a number. So before I write something really complicated, thought I would ask here.
If my number is 123456780
I want to display it as 123,456,780
And this needs to work for any number presented.
So if my number is 12345 then I want to display it as 12,345
Thanks
Lizette
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Thom Stone
2012-12-18 01:00:05 UTC
Permalink
The comma routine comes from Gerard Schildberger. He no longer appears on
this list, but I had seen him in some Rexx chat rooms a few years ago. I
believe someone clarified his routine a bit for the one provided.

From Gerald:

Yeah, a lot of my code gets compressed and downsized (as per # of REXX
statements). One of my favorites is the COMMA subroutine which will
add commas [or anything, for that matter, not just ONE character, or in
particular, some Europeans like to add periods (.) instead of commas (,)
to their numbers] to any kind of number with no excuses, and numbers
with leading/trailing/imbedded blanks in them ( + 4567 ) are
kept intact (the blanks that is).

Also, the number 0000000000000000001789 has just ONE comma added.

Also, the number may be exponentiated (12356.349737+2198), and of course,
may have a leading sign (which is kept intact). So many (other stupid)
routines use FORMAT to re-format the number, and leading plus signs
are stripped, as well as trailing insignificant zeroes. Also, my
routine will insert commas into numbers like $12345.87 or even
45693$CANADIAN or 17549megabytes. Also, it will handle numbers
of ANY size (length), without limitations of NUMERIC DIGITS. Here
is the little sucker (take with two aspirin):

======================================================================
comma: procedure; parse arg _,c,s; if c=='' then c=","
if \datatype(s,'W') | s<1 then s=3; n=_".9"; #=123456789 do
j=verify(n,#'0',,verify(n,#"0.",'M'))-s-1 to verify(n,#,"M") by -s
_=insert(c,_,j)
end
return _
======================================================================



Thanks,
Thom Stone
mailto:***@mchsi.com





-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of
Dave Salt
Sent: Monday, December 17, 2012 5:55 PM
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number

I forget where I got this but it does what you want:

/* REXX to add commas to a number. */
arg value
if value = "" then value = "1234567"
say "Adding commas to "value
n=value'.9'
do j=verify(n,1234567890,,verify(n,1234567890.,'M'))-4 to ,
verify(n,987654321,"M") by -3
value=insert(',',value,j)
end
say 'Value =' value


Dave Salt

SimpList(tm) - try it; you'll get it!

http://www.mackinney.com/products/program-development/simplist.html
Date: Mon, 17 Dec 2012 16:48:44 -0700
Subject: How to add commas to a number
List -
There does not appear to be a built-in for inserting commas into a number.
So before I write something really complicated, thought I would ask here.
If my number is 123456780
I want to display it as 123,456,780
And this needs to work for any number presented.
So if my number is 12345 then I want to display it as 12,345
Thanks
Lizette
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email
to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Bob Bridges
2012-12-21 00:46:47 UTC
Permalink
Just because it's hard to resist trying yet another solution, and not
because I think mine is necessarily better, here's my version. When judging
it by length, please take into account that it's constructed as a full
internal function with comment, PROCEDURE, ARG and RETURN statements:

/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a,c,z
s=left('',3-length(a)//3)a
do while s<>''; parse var s m 4 s; z=z m; end
return translate(strip(z),c,'')

I've a notion this might run a tad faster because it uses PARSE instead of
lots of fancier string functions - no REVERSE, for example. But even if I'm
right about that, it'll matter only if it's needed to run against thousands
of numbers.

addcomma('12345',',') : "12,345"
addcomma() : ""
addcomma('123456789abcde'): "12 345 678 9AB CDE"

---
Bob Bridges, ***@attglobal.net, cell 336 382-7313

/* One of the justifications for democracy is that everyone's interest
should be represented in government. But....the homeowner who locks his
door is looking out for his own interest just as much as the burglar who
picks the lock, but not exactly in the same way. The voter who wants to
keep his own money isn't seeking the same thing as the voter who wants the
state to give him someone else's money. -Joseph Sobran */

-----Original Message-----
From: Thom Stone
Sent: Monday, December 17, 2012 19:59

The comma routine comes from Gerard Schildberger. He no longer appears on
this list, but I had seen him in some Rexx chat rooms a few years ago. I
believe someone clarified his routine a bit for the one provided.

From Gerald:

Yeah, a lot of my code gets compressed and downsized (as per # of REXX
statements). One of my favorites is the COMMA subroutine which will
add commas [or anything, for that matter, not just ONE character, or in
particular, some Europeans like to add periods (.) instead of commas (,)
to their numbers] to any kind of number with no excuses, and numbers
with leading/trailing/imbedded blanks in them ( + 4567 ) are
kept intact (the blanks that is).

Also, the number 0000000000000000001789 has just ONE comma added.

Also, the number may be exponentiated (12356.349737+2198), and of course,
may have a leading sign (which is kept intact). So many (other stupid)
routines use FORMAT to re-format the number, and leading plus signs
are stripped, as well as trailing insignificant zeroes. Also, my
routine will insert commas into numbers like $12345.87 or even
45693$CANADIAN or 17549megabytes. Also, it will handle numbers
of ANY size (length), without limitations of NUMERIC DIGITS. Here
is the little sucker (take with two aspirin):

======================================================================
comma: procedure; parse arg _,c,s; if c=='' then c=","
if \datatype(s,'W') | s<1 then s=3; n=_".9"; #=123456789 do
j=verify(n,#'0',,verify(n,#"0.",'M'))-s-1 to verify(n,#,"M") by -s
_=insert(c,_,j)
end
return _
======================================================================
Date: Mon, 17 Dec 2012 16:48:44 -0700
If my number is 123456780, I want to display it as 123,456,780; and this
needs to work for any number presented. So if my number is 12345 then I
want to display it as 12,345.
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Vitonis, Tony
2012-12-21 03:42:01 UTC
Permalink
This violates the Principle of Least Astonishment for me: I'd expect the default behavior of "addcomma" to be to add a comma, not to add spaces.

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Bob Bridges
Sent: Thursday, December 20, 2012 7:46 PM
To: TSO-***@VM.MARIST.EDU
Subject: Re: How to add commas to a number

Just because it's hard to resist trying yet another solution, and not
because I think mine is necessarily better, here's my version. When judging
it by length, please take into account that it's constructed as a full
internal function with comment, PROCEDURE, ARG and RETURN statements:

/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a,c,z
s=left('',3-length(a)//3)a
do while s<>''; parse var s m 4 s; z=z m; end
return translate(strip(z),c,'')

I've a notion this might run a tad faster because it uses PARSE instead of
lots of fancier string functions - no REVERSE, for example. But even if I'm
right about that, it'll matter only if it's needed to run against thousands
of numbers.

addcomma('12345',',') : "12,345"
addcomma() : ""
addcomma('123456789abcde'): "12 345 678 9AB CDE"

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Paul Gilmartin
2012-12-18 00:17:46 UTC
Permalink
Post by Lizette Koehler
List -
There does not appear to be a built-in for inserting commas into a number. So before I write something really complicated, thought I would ask here.
If my number is 123456780
I want to display it as 123,456,780
And this needs to work for any number presented.
How big?

Floating point too? Scientific notation?
Post by Lizette Koehler
So if my number is 12345 then I want to display it as 12,345
I got this far:

***@MVS:130$ rexx "say reverse( translate( 'ABC,DEF,GHI,JKL', reverse( 12345678 ), 'ABCDEFGHIJKL' ) )"
, 12,345,678

Then you could STRIP off the leading commas and spaces.

But I'll bow to Dave's expertise.

-- gil

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Marc Irvin
2012-12-18 05:19:47 UTC
Permalink
This problem is a simple that has been done over and over. This is my solution.

PARSE ARG NUM '.' DEC
NUM = STRIP(NUM)
RVS = REVERSE(NUM)
X = ''
DO UNTIL RVS = ''
PARSE VAR RVS 1 Y 4 RVS
IF RVS <> '' THEN X = STRIP(X||Y','); ELSE X = STRIP(X||Y)
END
COM = REVERSE(X)
IF DEC <> '' THEN COM = COM'.'DEC
SAY 'BEFORE' STRIP(ARGSTRING)', AFTER' COM
EXIT COM

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Paul Gilmartin
Sent: Monday, December 17, 2012 7:18 PM
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number
Post by Lizette Koehler
List -
There does not appear to be a built-in for inserting commas into a number. So before I write something really complicated, thought I would ask here.
If my number is 123456780
I want to display it as 123,456,780
And this needs to work for any number presented.
How big?

Floating point too? Scientific notation?
Post by Lizette Koehler
So if my number is 12345 then I want to display it as 12,345
I got this far:

***@MVS:130$ rexx "say reverse( translate( 'ABC,DEF,GHI,JKL', reverse( 12345678 ), 'ABCDEFGHIJKL' ) )"
, 12,345,678

Then you could STRIP off the leading commas and spaces.

But I'll bow to Dave's expertise.

-- gil

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Lizette Koehler
2012-12-18 00:34:28 UTC
Permalink
Dave,

Thanks, I had the REVERSE, I did not do the Verify so my code was getting long in the tooth.

Lizette

-----Original Message-----
Sent: Dec 17, 2012 4:55 PM
Subject: Re: [TSO-REXX] How to add commas to a number
/* REXX to add commas to a number. */
arg value
if value = "" then value = "1234567"
say "Adding commas to "value
n=value'.9'
do j=verify(n,1234567890,,verify(n,1234567890.,'M'))-4 to ,
verify(n,987654321,"M") by -3
value=insert(',',value,j)
end
say 'Value =' value
Dave Salt
SimpList(tm) - try it; you'll get it!
http://www.mackinney.com/products/program-development/simplist.html
Date: Mon, 17 Dec 2012 16:48:44 -0700
Subject: How to add commas to a number
List -
There does not appear to be a built-in for inserting commas into a number. So before I write something really complicated, thought I would ask here.
If my number is 123456780
I want to display it as 123,456,780
And this needs to work for any number presented.
So if my number is 12345 then I want to display it as 12,345
Thanks
Lizette
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Phil Smith III
2012-12-21 13:42:37 UTC
Permalink
Ok, how about:

/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a '.' +0 d, comma
a = left('', 3-length(a)//3)a
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d

I like it because it gets to use INSERT(), which is almost never used!

...phsiii

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Styles, Andy , SMS - Scheduling and SCM Infrastructure Support
2012-12-21 14:12:57 UTC
Permalink
My turn :)

Two different options here. I wrote the recursive routine first, then thought maybe TRANSLATE could do it.. Not as powerful as Gerald's routine though.


X = '1234567895478297890765892652'

Say X
Say AddComma(x)

Fmt1 = Right('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',Length(X))
Fmt2 = Right('ABC,DEF,GHI,JKL,MNO,PQR,STU,VWX,YZ1,234,567,890',,
Trunc(Length(X)+Length(X)/3))

Say Translate(Fmt2,X,Fmt1)

Exit

AddComma: Procedure
Arg Num

If Length(Num) > 3 Then
Return AddComma(Left(Num,Length(Num)-3))','Right(Num,3)

Return Num
--
Andy Styles

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Phil Smith III
Sent: 21 December 2012 13:41
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number

Ok, how about:

/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a '.' +0 d, comma
a = left('', 3-length(a)//3)a
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d

I like it because it gets to use INSERT(), which is almost never used!

...phsiii

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Lloyds TSB Bank plc. Registered Office: 25 Gresham Street, London EC2V 7HN. Registered in England and Wales, number 2065. Telephone: 020 7626 1500.

Bank of Scotland plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 327000. Telephone: 020 7626 1500.

Lloyds TSB Scotland plc. Registered Office: Henry Duncan House, 120 George Street, Edinburgh EH2 4LH. Registered in Scotland, number 95237. Telephone: 0131 225 4555.

Cheltenham & Gloucester plc. Registered Office: Barnett Way, Gloucester GL4 3RL. Registered in England and Wales, number 2299428. Telephone: 01452 372372.

Lloyds TSB Bank plc, Lloyds TSB Scotland plc, Bank of Scotland plc and Cheltenham & Gloucester plc are authorised and regulated by the Financial Services Authority.

Halifax is a division of Bank of Scotland plc. Cheltenham & Gloucester Savings is a division of Lloyds TSB Bank plc.

HBOS plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 218813. Telephone: 020 7626 1500.

Lloyds Banking Group plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 95000. Telephone: 0131 225 4555

This e-mail (including any attachments) is private and confidential and may contain privileged material. If you have received this e-mail in error, please notify the sender and delete it (including any attachments) immediately. You must not copy, distribute, disclose or use any of the information in it or any attachments.

Telephone calls may be monitored or recorded.

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Walter Pachl
2012-12-21 14:37:19 UTC
Permalink
for AddComma(123456789.1234,',') you get ',123,456,789.1234'
so better another strip(a,,',')
Season's greetings
Walter
Post by Bob Bridges
/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a '.' +0 d, comma
a = left('', 3-length(a)//3)a
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d
I like it because it gets to use INSERT(), which is almost never used!
...phsiii
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Ken MacKenzie
2012-12-21 14:48:02 UTC
Permalink
I have this in a working example:
ddifx = Right(Abs(ddif), 9, '0')
ddifx = Translate('ABC,DEF,GHI', ddifx, 'ABCDEFGHI')
ddifx = Strip(ddifx, 'L', '0')
ddifx = Strip(ddifx, 'L', ',')
ddifx = Strip(ddifx, 'L', '0')
ddifx = Strip(ddifx, 'L', ',')
ddifx = Strip(ddifx, 'L', '0')

Not the repeated STRIP of commas and zeroes - I guess if I wanted longer
strings I could have put them in a loop.




From: Walter Pachl <***@CHELLO.AT>
To: TSO-***@VM.MARIST.EDU,
Date: 21/12/2012 14:41
Subject: Re: [TSO-REXX] How to add commas to a number
Sent by: TSO REXX Discussion List <TSO-***@VM.MARIST.EDU>



for AddComma(123456789.1234,',') you get ',123,456,789.1234'
so better another strip(a,,',')
Season's greetings
Walter
Post by Bob Bridges
/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a '.' +0 d, comma
a = left('', 3-length(a)//3)a
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d
I like it because it gets to use INSERT(), which is almost never used!
...phsiii
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX


----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Styles, Andy , SMS - Scheduling and SCM Infrastructure Support
2012-12-21 14:55:03 UTC
Permalink
I never claimed it worked for numbers than integers :-)


Andy Styles
Endevor Technical Specialist | zSCM | Service Delivery

2S81 Emerald House | 25 Lavington Street | London | SE1 0NA
Network: 7430 3374 | Office: 020 7922 3374 | email: ***@LloydsBanking.com

zSCM Sharepoint http://teamspace.intranet.group/sites/Endevor/


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Walter Pachl
Sent: 21 December 2012 14:19
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number

for AddComma(123456789.1234,',') you get ',123,456,789.1234'
so better another strip(a,,',')
Season's greetings
Walter
Post by Bob Bridges
/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a '.' +0 d, comma
a = left('', 3-length(a)//3)a
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d
I like it because it gets to use INSERT(), which is almost never used!
...phsiii
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Lloyds TSB Bank plc. Registered Office: 25 Gresham Street, London EC2V 7HN. Registered in England and Wales, number 2065. Telephone: 020 7626 1500.

Bank of Scotland plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 327000. Telephone: 020 7626 1500.

Lloyds TSB Scotland plc. Registered Office: Henry Duncan House, 120 George Street, Edinburgh EH2 4LH. Registered in Scotland, number 95237. Telephone: 0131 225 4555.

Cheltenham & Gloucester plc. Registered Office: Barnett Way, Gloucester GL4 3RL. Registered in England and Wales, number 2299428. Telephone: 01452 372372.

Lloyds TSB Bank plc, Lloyds TSB Scotland plc, Bank of Scotland plc and Cheltenham & Gloucester plc are authorised and regulated by the Financial Services Authority.

Halifax is a division of Bank of Scotland plc. Cheltenham & Gloucester Savings is a division of Lloyds TSB Bank plc.

HBOS plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 218813. Telephone: 020 7626 1500.

Lloyds Banking Group plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 95000. Telephone: 0131 225 4555

This e-mail (including any attachments) is private and confidential and may contain privileged material. If you have received this e-mail in error, please notify the sender and delete it (including any attachments) immediately. You must not copy, distribute, disclose or use any of the information in it or any attachments.

Telephone calls may be monitored or recorded.
Styles, Andy , SMS - Scheduling and SCM Infrastructure Support
2012-12-21 15:34:54 UTC
Permalink
How about:

/* REXX */

X = '12345.6789'

Say X
Say AddComma(x)

Exit

AddComma: Procedure
Arg Num

Parse Var Num Int'.'Dec

If Dec ¬= '' Then
Dec = '.'||Dec

If Length(Int) > 3 Then
Return AddComma(Left(Int,Length(Int)-3))','Right(Int,3)||Dec

Return Num||Dec
--
Andy Styles

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Styles, Andy (SMS - Scheduling and SCM Infrastructure Support)
Sent: 21 December 2012 14:53
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number

I never claimed it worked for numbers than integers :-)


Andy Styles
Endevor Technical Specialist | zSCM | Service Delivery

2S81 Emerald House | 25 Lavington Street | London | SE1 0NA
Network: 7430 3374 | Office: 020 7922 3374 | email: ***@LloydsBanking.com

zSCM Sharepoint http://teamspace.intranet.group/sites/Endevor/


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Walter Pachl
Sent: 21 December 2012 14:19
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number

for AddComma(123456789.1234,',') you get ',123,456,789.1234'
so better another strip(a,,',')
Season's greetings
Walter
Post by Bob Bridges
/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a '.' +0 d, comma
a = left('', 3-length(a)//3)a
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d
I like it because it gets to use INSERT(), which is almost never used!
...phsiii
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX Lloyds TSB Bank plc. Registered Office: 25 Gresham Street, London EC2V 7HN. Registered in England and Wales, number 2065. Telephone: 020 7626 1500.

Bank of Scotland plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 327000. Telephone: 020 7626 1500.

Lloyds TSB Scotland plc. Registered Office: Henry Duncan House, 120 George Street, Edinburgh EH2 4LH. Registered in Scotland, number 95237. Telephone: 0131 225 4555.

Cheltenham & Gloucester plc. Registered Office: Barnett Way, Gloucester GL4 3RL. Registered in England and Wales, number 2299428. Telephone: 01452 372372.

Lloyds TSB Bank plc, Lloyds TSB Scotland plc, Bank of Scotland plc and Cheltenham & Gloucester plc are authorised and regulated by the Financial Services Authority.

Halifax is a division of Bank of Scotland plc. Cheltenham & Gloucester Savings is a division of Lloyds TSB Bank plc.

HBOS plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 218813. Telephone: 020 7626 1500.

Lloyds Banking Group plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 95000. Telephone: 0131 225 4555

This e-mail (including any attachments) is private and confidential and may contain privileged material. If you have received this e-mail in error, please notify the sender and delete it (including any attachments) immediately. You must not copy, distribute, disclose or use any of the information in it or any attachments.

Telephone calls may be monitored or recorded.
Lloyds TSB Bank plc. Registered Office: 25 Gresham Street, London EC2V 7HN. Registered in England and Wales, number 2065. Telephone: 020 7626 1500.

Bank of Scotland plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 327000. Telephone: 020 7626 1500.

Lloyds TSB Scotland plc. Registered Office: Henry Duncan House, 120 George Street, Edinburgh EH2 4LH. Registered in Scotland, number 95237. Telephone: 0131 225 4555.

Cheltenham & Gloucester plc. Registered Office: Barnett Way, Gloucester GL4 3RL. Registered in England and Wales, number 2299428. Telephone: 01452 372372.

Lloyds TSB Bank plc, Lloyds TSB Scotland plc, Bank of Scotland plc and Cheltenham & Gloucester plc are authorised and regulated by the Financial Services Authority.

Halifax is a division of Bank of Scotland plc. Cheltenham & Gloucester Savings is a division of Lloyds TSB Bank plc.

HBOS plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 218813. Telephone: 020 7626 1500.

Lloyds Banking Group plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 95000. Telephone: 0131 225 4555

This e-mail (including any attachments) is private and confidential and may contain privileged material. If you have received this e-mail in error, please notify the sender and delete it (including any attachments) immediately. You must not copy, distribute, disclose or use any of the information in it or any attachments.

Telephone calls may be monitored or recorded.
Marc Irvin
2012-12-21 16:24:11 UTC
Permalink
Test.

Did anyone see my test commas offering. I didn't but I was thinking the server does not send to the sendee. Mine is tested over the long haul in many of my apps. Also, I want to confirm my active membership. Could I be blocked or quarantined?

Marc Irvin

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Bob Bridges
2012-12-21 20:30:56 UTC
Permalink
I went back to my archives and found the one below, Marc; is it the one
you're asking about?

---
Bob Bridges, ***@attglobal.net, cell 336 382-7313

/* Be careful of your thoughts; they may become words at any moment. -Ira
Gassen */

-----Original Message-----
From: Marc Irvin
Sent: Friday, December 21, 2012 11:15

Test.

Did anyone see my test commas offering. I didn't but I was thinking the
server does not send to the sendee. Mine is tested over the long haul in
many of my apps. Also, I want to confirm my active membership. Could I
be blocked or quarantined?

-----Original Message-----
From: Marc Irvin
Sent: Tuesday, December 18, 2012 00:17

This problem is a simple that has been done over and over. This is my
solution.

PARSE ARG NUM '.' DEC
NUM = STRIP(NUM)
RVS = REVERSE(NUM)
X = ''
DO UNTIL RVS = ''
PARSE VAR RVS 1 Y 4 RVS
IF RVS <> '' THEN X = STRIP(X||Y','); ELSE X = STRIP(X||Y)
END
COM = REVERSE(X)
IF DEC <> '' THEN COM = COM'.'DEC
SAY 'BEFORE' STRIP(ARGSTRING)', AFTER' COM
EXIT COM

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Marc Irvin
2012-12-22 18:47:34 UTC
Permalink
Bob,

Yes, but some of the carriage returns are missing. Why is it only in the
archives?

Marc

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of
Bob Bridges
Sent: Friday, December 21, 2012 3:30 PM
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] Test from Marc Irvin (was How to add commas to a
number)

I went back to my archives and found the one below, Marc; is it the one
you're asking about?

---
Bob Bridges, ***@attglobal.net, cell 336 382-7313

/* Be careful of your thoughts; they may become words at any moment. -Ira
Gassen */

-----Original Message-----
From: Marc Irvin
Sent: Friday, December 21, 2012 11:15

Test.

Did anyone see my test commas offering. I didn't but I was thinking the
server does not send to the sendee. Mine is tested over the long haul in
many of my apps. Also, I want to confirm my active membership. Could I
be blocked or quarantined?

-----Original Message-----
From: Marc Irvin
Sent: Tuesday, December 18, 2012 00:17

This problem is a simple that has been done over and over. This is my
solution.

PARSE ARG NUM '.' DEC
NUM = STRIP(NUM)
RVS = REVERSE(NUM)
X = ''
DO UNTIL RVS = ''
PARSE VAR RVS 1 Y 4 RVS
IF RVS <> '' THEN X = STRIP(X||Y','); ELSE X = STRIP(X||Y)
END
COM = REVERSE(X)
IF DEC <> '' THEN COM = COM'.'DEC
SAY 'BEFORE' STRIP(ARGSTRING)', AFTER' COM EXIT COM

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email
to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Bob Bridges
2012-12-24 02:10:40 UTC
Permalink
Oh, I didn't mean it was in the listserv archives, Marc, only in mine, ie
the folder where I toss TSO-REXX email after I've read it.

My guess is I'm not the only one seeing your email, but that it's coming
through just fine. YOU'RE not seeing it (and you alone) because of a
setting that you can change. In fact I have the same setting for TSO-REXX,
though I keep meaning to change it. I can read my posts to RACF-L, but my
posts to TSO-REXX don't show up because of a setting that tells the listserv
software not to bother showing me my own posts. As I said, I keep meaning
to look up that setting in the HELP files and change it, but I keep not
getting around to it. Let's see whether I can find it in my old notes....
Here it is; apparently if I can get the command SET REPRO to the listserv
machine, it'll start including me on my own postings to TSO-REXX. By "the
listserv machine" I don't mean the same email address that we send email to,
but to the one you used to subscribe in the first place. Anyone here
remember that address?

---
Bob Bridges, ***@attglobal.net, cell 336 382-7313

/* One of the justifications for democracy is that everyone's interest
should be represented in government. But....the homeowner who locks his
door is looking out for his own interest just as much as the burglar who
picks the lock, but not exactly in the same way. The voter who wants to
keep his own money isn't seeking the same thing as the voter who wants the
state to give him someone else's money. -Joseph Sobran */

-----Original Message-----
From: Marc Irvin
Sent: Saturday, December 22, 2012 13:46

Yes, but some of the carriage returns are missing. Why is it only in the
archives?

-----Original Message-----
From: Bob Bridges
Sent: Friday, December 21, 2012 3:30 PM

I went back to my archives and found the one below, Marc; is it the one
you're asking about?

-----Original Message-----
From: Marc Irvin
Sent: Friday, December 21, 2012 11:15

Did anyone see my test commas offering. I didn't but I was thinking the
server does not send to the sendee. Mine is tested over the long haul in
many of my apps. Also, I want to confirm my active membership. Could I
be blocked or quarantined?

-----Original Message-----
From: Marc Irvin
Sent: Tuesday, December 18, 2012 00:17

This problem is a simple that has been done over and over. This is my
solution.

PARSE ARG NUM '.' DEC
NUM = STRIP(NUM)
RVS = REVERSE(NUM)
X = ''
DO UNTIL RVS = ''
PARSE VAR RVS 1 Y 4 RVS
IF RVS <> '' THEN X = STRIP(X||Y','); ELSE X = STRIP(X||Y)
END
COM = REVERSE(X)
IF DEC <> '' THEN COM = COM'.'DEC
SAY 'BEFORE' STRIP(ARGSTRING)', AFTER' COM EXIT COM

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Don Imbriale
2012-12-24 02:14:36 UTC
Permalink
To send a message to all the people currently subscribed to the list,
just send mail to TSO-***@VM.MARIST.EDU. This is called "sending mail to
the list," because you send mail to a single address and LISTSERV makes
copies for all the people who have subscribed. This address
(TSO-***@VM.MARIST.EDU) is also called the "list address." You must
never try to send any command to that address, as it would be distributed
to all the people who have subscribed. All commands must be sent to the
"LISTSERV address," ***@VM.MARIST.EDU (or ***@MARIST.BITNET).
It is very important to understand the difference between the two, but
fortunately it is not complicated. The LISTSERV address is like a FAX
number that connects you to a machine, whereas the list address is like a
normal voice line connecting you to a person. If you make a mistake and
dial the FAX number when you wanted to talk to someone on the phone, you
will quickly realize that you used the wrong number and call again. No
harm will have been done. If on the other hand you accidentally make your
FAX call someone's voice line, the person receiving the call will be
inconvenienced, especially if your FAX then re-dials every 5 minutes. The
fact that most people will eventually connect the FAX machine to the
voice line to allow the FAX to go through and make the calls stop does
not mean that you should continue to send FAXes to the voice number.
People would just get mad at you. It works pretty much the same way with
mailing lists, with the difference that you are calling hundreds or
thousands of people at the same time, and consequently you can expect a
lot of people to get upset if you consistently send commands to the list
address.

You may leave the list at any time by sending a "SIGNOFF TSO-REXX"
command to ***@VM.MARIST.EDU (or ***@MARIST.BITNET). You can
also tell LISTSERV how you want it to confirm the receipt of messages you
send to the list. If you do not trust the system, send a "SET TSO-REXX
REPRO" command and LISTSERV will send you a copy of your own messages, so
that you can see that the message was distributed and did not get damaged
on the way. After a while you may find that this is getting annoying,
especially if your mail program does not tell you that the message is
from you when it informs you that new mail has arrived from TSO-REXX. If
you send a "SET TSO-REXX ACK NOREPRO" command, LISTSERV will mail you a
short acknowledgement instead, which will look different in your mailbox
directory. With most mail programs you will know immediately that this is
an acknowledgement you can read later. Finally, you can turn off
acknowledgements completely with "SET TSO-REXX NOACK NOREPRO".

Following instructions from the list owner, your subscription options
have been set to "SUBJECTHDR" rather than the usual LISTSERV defaults.
For more information about subscription options, send a "QUERY TSO-REXX"
command to ***@VM.MARIST.EDU (or ***@MARIST.BITNET).

Contributions sent to this list are automatically archived. You can get a
list of the available archive files by sending an "INDEX TSO-REXX"
command to ***@VM.MARIST.EDU (or ***@MARIST.BITNET). You can
then order these files with a "GET TSO-REXX LOGxxxx" command, or using
LISTSERV's database search facilities. Send an "INFO DATABASE" command
for more information on the latter.

This list is available in digest form. If you wish to receive the
digested version of the postings, just issue a SET TSO-REXX DIGEST
command.

More information on LISTSERV commands can be found in the LISTSERV
reference card, which you can retrieve by sending an "INFO REFCARD"
command to ***@VM.MARIST.EDU (or ***@MARIST.BITNET).

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Adrian Stern
2012-12-21 17:39:50 UTC
Permalink
I can't test this but why not something in the style of:

Do i=length(integer) to 1 by -1
If pos<4 then
Do
NewInteger=NewInteger || integer(i)
Pos=pos+1
End
else
Do
NewInteger=NewInteger || "," || integer(i)
Pos=1
End
End

Should work I think

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Styles, Andy (SMS - Scheduling and SCM Infrastructure Support)
Sent: den 21 december 2012 16:13
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number

How about:

/* REXX */

X = '12345.6789'

Say X
Say AddComma(x)

Exit

AddComma: Procedure
Arg Num

Parse Var Num Int'.'Dec

If Dec ¬= '' Then
Dec = '.'||Dec

If Length(Int) > 3 Then
Return AddComma(Left(Int,Length(Int)-3))','Right(Int,3)||Dec

Return Num||Dec
--
Andy Styles

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Styles, Andy (SMS - Scheduling and SCM Infrastructure Support)
Sent: 21 December 2012 14:53
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number

I never claimed it worked for numbers than integers :-)


Andy Styles
Endevor Technical Specialist | zSCM | Service Delivery

2S81 Emerald House | 25 Lavington Street | London | SE1 0NA
Network: 7430 3374 | Office: 020 7922 3374 | email: ***@LloydsBanking.com

zSCM Sharepoint http://teamspace.intranet.group/sites/Endevor/


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Walter Pachl
Sent: 21 December 2012 14:19
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number

for AddComma(123456789.1234,',') you get ',123,456,789.1234'
so better another strip(a,,',')
Season's greetings
Walter
Post by Bob Bridges
/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a '.' +0 d, comma
a = left('', 3-length(a)//3)a
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d
I like it because it gets to use INSERT(), which is almost never used!
...phsiii
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX Lloyds TSB Bank plc. Registered Office: 25 Gresham Street, London EC2V 7HN. Registered in England and Wales, number 2065. Telephone: 020 7626 1500.

Bank of Scotland plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 327000. Telephone: 020 7626 1500.

Lloyds TSB Scotland plc. Registered Office: Henry Duncan House, 120 George Street, Edinburgh EH2 4LH. Registered in Scotland, number 95237. Telephone: 0131 225 4555.

Cheltenham & Gloucester plc. Registered Office: Barnett Way, Gloucester GL4 3RL. Registered in England and Wales, number 2299428. Telephone: 01452 372372.

Lloyds TSB Bank plc, Lloyds TSB Scotland plc, Bank of Scotland plc and Cheltenham & Gloucester plc are authorised and regulated by the Financial Services Authority.

Halifax is a division of Bank of Scotland plc. Cheltenham & Gloucester Savings is a division of Lloyds TSB Bank plc.

HBOS plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 218813. Telephone: 020 7626 1500.

Lloyds Banking Group plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 95000. Telephone: 0131 225 4555

This e-mail (including any attachments) is private and confidential and may contain privileged material. If you have received this e-mail in error, please notify the sender and delete it (including any attachments) immediately. You must not copy, distribute, disclose or use any of the information in it or any attachments.

Telephone calls may be monitored or recorded.
Lloyds TSB Bank plc. Registered Office: 25 Gresham Street, London EC2V 7HN. Registered in England and Wales, number 2065. Telephone: 020 7626 1500.

Bank of Scotland plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 327000. Telephone: 020 7626 1500.

Lloyds TSB Scotland plc. Registered Office: Henry Duncan House, 120 George Street, Edinburgh EH2 4LH. Registered in Scotland, number 95237. Telephone: 0131 225 4555.

Cheltenham & Gloucester plc. Registered Office: Barnett Way, Gloucester GL4 3RL. Registered in England and Wales, number 2299428. Telephone: 01452 372372.

Lloyds TSB Bank plc, Lloyds TSB Scotland plc, Bank of Scotland plc and Cheltenham & Gloucester plc are authorised and regulated by the Financial Services Authority.

Halifax is a division of Bank of Scotland plc. Cheltenham & Gloucester Savings is a division of Lloyds TSB Bank plc.

HBOS plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 218813. Telephone: 020 7626 1500.

Lloyds Banking Group plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland, number 95000. Telephone: 0131 225 4555

This e-mail (including any attachments) is private and confidential and may contain privileged material. If you have received this e-mail in error, please notify the sender and delete it (including any attachments) immediately. You must not copy, distribute, disclose or use any of the information in it or any attachments.

Telephone calls may be monitored or recorded.

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Phil Smith III
2012-12-21 17:06:10 UTC
Permalink
Oops, not enough testing. More to come...!

-----Original Message-----
From: Walter Pachl [mailto:***@chello.at]
Sent: Friday, December 21, 2012 9:19 AM
To: TSO REXX Discussion List
Cc: Phil Smith III
Subject: Re: [TSO-REXX] How to add commas to a number

for AddComma(123456789.1234,',') you get ',123,456,789.1234'
so better another strip(a,,',')
Season's greetings
Walter
Post by Bob Bridges
/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a '.' +0 d, comma
a = left('', 3-length(a)//3)a
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d
I like it because it gets to use INSERT(), which is almost never used!
...phsiii
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Phil Smith III
2012-12-21 17:49:30 UTC
Permalink
Better:

/* Call: "AddComma(12345,',')" */
AddCommas: procedure
parse arg a '.' +0 d, comma
a = right(a, ((length(a)+2)%3)*3)
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d

-----Original Message-----
From: Walter Pachl [mailto:***@chello.at]
Sent: Friday, December 21, 2012 9:19 AM
To: TSO REXX Discussion List
Cc: Phil Smith III
Subject: Re: [TSO-REXX] How to add commas to a number

for AddComma(123456789.1234,',') you get ',123,456,789.1234'
so better another strip(a,,',')
Season's greetings
Walter
Post by Bob Bridges
/* Call: "AddComma(12345,',')" */
AddComma: procedure
parse arg a '.' +0 d, comma
a = left('', 3-length(a)//3)a
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d
I like it because it gets to use INSERT(), which is almost never used!
...phsiii
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Bob Bridges
2012-12-21 20:39:25 UTC
Permalink
I can't imagine how we all missed it, but Adrian's version got me thinking
about something that he saw and should have been obvious to me too: Instead
of all that fancy REVERSE and TRANSLATE, and my use of the // operator,
isn't this a lot simpler?

do pos=length(num)-3 to 1 by -3; num=insert(com,num,pos); end

Make your own adjustments for decimal points and scientific notation, if
necessary.

---
Bob Bridges, ***@attglobal.net, cell 336 382-7313

/* re-cur-sive (ri: 'kr sIv), from "re-" + Lat. "cursire" (to say "Oh, hell,
not AGAIN!"): See "recursive". */

-----Original Message-----
From: Phil Smith III
Sent: Friday, December 21, 2012 12:48

/* Call: "AddComma(12345,',')" */
AddCommas: procedure
parse arg a '.' +0 d, comma
a = right(a, ((length(a)+2)%3)*3)
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d


-----Original Message-----
From: Adrian Stern
Sent: Friday, December 21, 2012 12:38

I can't test this but why not something in the style of:

Do i=length(integer) to 1 by -1
If pos<4 then
Do
NewInteger=NewInteger || integer(i)
Pos=pos+1
End
else
Do
NewInteger=NewInteger || "," ||
integer(i)
Pos=1
End
End

Should work I think

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Marc Irvin
2012-12-22 19:53:00 UTC
Permalink
Bob,

What do I need to do to get visable?

Bob, I liked your last version so much that I've upgraded my version. It
includes logic to strip off superfluous zeroes (i.e. 000999.999000). My
function now reads...


CommaTize:
parse arg num
if datatype(num) = 'NUM' then do
parse value strip(num) with num '.' dec
num = num+0
do pos=length(num)-3 to 1 by -3; num=insert(',',num,pos); end
if dec \= '' then num = num'.'reverse(reverse(dec)+0)
end
return num



-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of
Bob Bridges
Sent: Friday, December 21, 2012 3:38 PM
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] How to add commas to a number

I can't imagine how we all missed it, but Adrian's version got me thinking
about something that he saw and should have been obvious to me too: Instead
of all that fancy REVERSE and TRANSLATE, and my use of the // operator,
isn't this a lot simpler?

do pos=length(num)-3 to 1 by -3; num=insert(com,num,pos); end

Make your own adjustments for decimal points and scientific notation, if
necessary.

---
Bob Bridges, ***@attglobal.net, cell 336 382-7313

/* re-cur-sive (ri: 'kr sIv), from "re-" + Lat. "cursire" (to say "Oh, hell,
not AGAIN!"): See "recursive". */

-----Original Message-----
From: Phil Smith III
Sent: Friday, December 21, 2012 12:48

/* Call: "AddComma(12345,',')" */
AddCommas: procedure
parse arg a '.' +0 d, comma
a = right(a, ((length(a)+2)%3)*3)
do i = 1 to (length(a)%3)-1
a = insert(comma, a, (4*i)-1)
end
return strip(a) || d


-----Original Message-----
From: Adrian Stern
Sent: Friday, December 21, 2012 12:38

I can't test this but why not something in the style of:

Do i=length(integer) to 1 by -1
If pos<4 then
Do
NewInteger=NewInteger || integer(i)
Pos=pos+1
End
else
Do
NewInteger=NewInteger || "," ||
integer(i)
Pos=1
End
End

Should work I think

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email
to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Pete Hartung
2012-12-27 04:27:44 UTC
Permalink
My two cents.

/* REXX #InsCmma: Insert commas into a numeric string */
total = -1.234567891e+12
say left(total,25) #InsCmma(total)
total = ' 12345678912345.6e-10'
say left(total,25) #InsCmma(total)
total = '+000001234567.852'
say left(total,25)#InsCmma(total)
total = '-123456.7853'
say left(total,25)#InsCmma(total)
total = '-123456.7853'
say left(total,25)#InsCmma(format(total,,2)) /* round 2 decimals */
exit
#InsCmma: Procedure
Arg !Number
Numeric digits 32 /* to handle large numbers */
!Number = !Number + 0 /* remove leading zeros and exponential notation*/
Do !c = pos('.',!Number'.')-4 to lastpos('-','-'!Number) by -3
!Number = insert(',',!Number,!c)
End
Return !Number
/* */

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Lizette Koehler
Sent: Monday, December 17, 2012 6:49 PM
To: TSO-***@VM.MARIST.EDU
Subject: [TSO-REXX] How to add commas to a number

List -

There does not appear to be a built-in for inserting commas into a number. So before I write something really complicated, thought I would ask here.

If my number is 123456780

I want to display it as 123,456,780

And this needs to work for any number presented.

So if my number is 12345 then I want to display it as 12,345



Thanks

Lizette

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Loading...