Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Currency Numbers



kai wrote on Mon, 19 Jun 2006 19:16:06 +0100:

>on currency_format for v
>	set {s, d} to {(0 as real as text)'s character 2, (round (v mod 1 *  
>100)) / 100 as string}
>	(v div 1 as text) & s & text 1 thru 2 of (d's text ((offset of s in  
>d) + 1) thru -1 & "00")
>end currency_format
>
>currency_format for -123.4
>
>--> "-123,40" (* on a French system *)

OK. Bearing in mind Gary's historical treatise and kai's love of one-
liners, how about this?

  on currency_format for v
    tell (v mod 1 as string) * 100 to tell (it * it) ^ 0.5 to return (v
div 1 as string) & (0.0 as string)'s middle character & (it div 0.5 - it
div 1)
  end currency_format
  
  currency_format for -123.4
  
  --> "-123,40" (* on a French system *)

If I switch my machine over to French and French numbers, it's only in
strings that the decimal point is a comma. It still appears as a dot in
reals in Script Editor. Is that true for French users or have I missed
something?

NG

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.