• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How can I format an integer ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
echo email@hidden@nl | tr a-z@. p-za-o.@

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

  • Follow-Ups:
    • Re: How can I format an integer ?
      • From: Andrea D'Amore <email@hidden>
    • Re: How can I format an integer ?
      • From: Luther Fuller <email@hidden>
References: 
 >Re: How can I format an integer ? (From: Barry Wainwright <email@hidden>)

  • Prev by Date: Re: Remove application icon from dock
  • Next by Date: Re: How can I format an integer ?
  • Previous by thread: Re: How can I format an integer ?
  • Next by thread: Re: How can I format an integer ?
  • Index(es):
    • Date
    • Thread