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



Cheers kai,

Your code below worked a treat. I did treat other suggestion but they only gave me one decimal place.

However, I have had to put it as straight code rather than as a handler due to the fact that I get the error: Can't continue currency_format.

I had written the call to the handler as follows:

set strCatBSP to currency_format(strCatBSP)

I have tried to call the handler will being within 'tell application "Finder"' and 'tell application 'MacSQL3"', just in case this made a difference. Does it?

Any help would be grateful received but not desperate.

Cheers to everyone else who sent in suggestions.

David Bradley
Senior Web Programmer
Globe Media
Brookfields Way
Manvers
Wath upon Dearne
Rotherham
S63 5DL

Tel: 01709 768000
Fax: 01709 768011
www.globe-media.com




On 19 Jun 2006, at 18:50, kai wrote:


On 19 Jun 2006, at 16:08, David Bradley wrote:

To check how many characters are after the decimal point and then add one or two zeros if necessary.

Since the aim is that specific, I suppose something relatively simple might do it:

------------------

on currency_format for v
set d to (round (v mod 1 * 100)) / 100 as string
(v div 1 as text) & "." & text 1 thru 2 of (d's text ((offset of "." in d) + 1) thru -1 & "00")
end currency_format

currency_format for -123.4
--> "-123.40"

------------------

---
kai


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

This email sent to email@hidden


 _______________________________________________
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

References: 
 >Currency Numbers (From: David Bradley <email@hidden>)
 >Re: Currency Numbers (From: Gary Tate <email@hidden>)
 >Re: Currency Numbers (From: David Bradley <email@hidden>)
 >Re: Currency Numbers (From: kai <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.