Re: How can I format an integer ?
Re: How can I format an integer ?
- Subject: Re: How can I format an integer ?
- From: Philip Aker <email@hidden>
- Date: Tue, 4 Nov 2008 15:22:36 -0800
On 2008-11-04, at 13:27:07, Barry Wainwright wrote: here's the routine I use:
on commafy(theNum) -- A recursive routine that converts an integer to a western formatted -- number with commas between the 'thousand' groupings if theNum > 999 then return (commafy(theNum div 1000) & "," & text -3 thru -1 of ("00" & ((theNum mod 1000) as text))) return theNum as text end commafy
Thanks Barry, using recursion seems like a more logical approach.
on FormatInt(theNum, theSeparator) if theNum > 999 then return (FormatInt(theNum div 1000, theSeparator) & theSeparator & text -3 thru -1 of ("00" & ((theNum mod 1000) as text))) return theNum as text end FormatInt FormatInt(9.99999999E+8, ",")
Philip Aker
Democracy: Two wolves and a sheep voting on lunch. |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden