Re: How can I format an integer ?
Re: How can I format an integer ?
- Subject: Re: How can I format an integer ?
- From: Philip Aker <email@hidden>
- Date: Thu, 6 Nov 2008 01:54:08 -0800
On 2008-11-06, at 01:39:16, André Berg wrote:
I get the same results and its not just limited to reals in scientific
notation, but any real to string coercion.
Ugh, I don't know how many workarounds I had to script because
of that pesky locale settings which is reckognized by AppleScript
per se but not by 'do shell script' which uses a virgin/default
/bin/sh ><
I was always wondering if there wasn't some (hidden?) setting one
could change like with text item delimiters. You set it before you
do the conversion from real to string and AS uses that setting.
Or do I really have to pipe all my shell scripts thru 'sed -E -e
s/,/./g'
before actually using them?
Hi André,
My previous post arrived at an explanation and an alternate solution.
Apologies if this is regarded as trolling, but I thought a
discussion of AppleScript's default decimal separator still has
something to do with formatting a number.
Wail away, but better still file a bug. It's a serious limitation that
should be addressed. Maybe one big headache for the fixer is that it's
got 15+ years of baggage to account for one way or another.
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, ",")
The example above doesn't give expected result on my system, I get
"999,999,9,0" .
From what I can see there's a problem coercing a real in
exponential form to integer, last comma is due to my locale setting.
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