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.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-users/gary%
40tgisolutions.co.uk
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-users/dave%
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: http://lists.apple.com/mailman/options/applescript-users/inemo%
40mac.com