Re: Currency Numbers
Re: Currency Numbers
- Subject: Re: Currency Numbers
- From: email@hidden
- Date: Mon, 19 Jun 2006 17:12:57 +0100
Heres a quick script I've just knocked together. I'm sure there is
an easier way to do this, and that someone will point out how
repetitive this code is (heh!)
Only limitation I know of is that it will error out if the number
doesn't have a . (period) on the end.
--> Start Script <--
(* Setup variables *)
property e : true
property f : true
property g : true
set a to "0.52314" -- the number to be used
set text item delimiters to "."
set b to text items of a
-- I do this so as to reset them to default.
set text item delimiters to ""
set z to item 1 of b
set c to item 2 of b
set d to text items of c
try
if exists item 3 of d then -- number is y.xxx or longer [no zero's
needed]
set e to true
end if
on error
set e to false
end try
if e is true then
set y to item 1 of d
set x to item 2 of d
end if
if e is false then -- number is shorter than y.xxx [zero's needed,
but how many]
try
if exists item 2 of d then
set y to item 1 of d
set x to item 2 of d
set f to true
end if
on error
set f to false
end try
end if
if f is equal to false then -- number is shorter than y.xx [at least
1 zero needed]
try
if exists item 1 of d then -- number is y.x and needed trailing zero
set y to item 1 of d
set x to "0"
set g to true
end if
on error
set g to false
end try
end if
if g is equal to false then -- number is y. [two zero's needed]
set y to "0"
set x to "0"
end if
set endNum to z & "." & y & x
--> End Script <--
This was done quickly so could do with some improving.
Caius
________________________
Caius Durling
College Student (UK)
tel: +447738678832
email: email@hidden
web: http://caius.name/
________________________
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.
David Bradley
Senior Web Programmer
Globe Media
Eastwood Works
Fitzwilliam Road
Rotherham
S65 1JU
Tel: 01709 364721
Fax: 01709 515225
email@hidden
www.globe-media.com
On 19 Jun 2006, at 16:00, Gary Tate wrote:
What are you trying to do with the numbers?
You can strip them down (or build up) using string manipulation.
ie check how many characters after the decimal point and either
add zeroes, or remove them.
Gary
On 19 Jun 2006, at 15:55, David Bradley wrote:
Hi,
Can you format numbers to 2 decimal points in Applescript. I want
to format the numbers in to a currency format
Cheers
David Bradley
Senior Web Programmer
Globe Media
Eastwood Works
Fitzwilliam Road
Rotherham
S65 1JU
Tel: 01709 364721
Fax: 01709 515225
email@hidden
www.globe-media.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40tgisolutions.co.uk
This email sent to email@hidden
-------------------------------------------------------
TGI Solutions LLP
Apple Solution Expert
http://www.tgisolutions.co.uk
Mobile: 07813 214 129
-------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40globe-media.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
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:
This email sent to email@hidden