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