• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Exponential notation [was: Re: How to calculate/process this one?]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exponential notation [was: Re: How to calculate/process this one?]


  • Subject: Re: Exponential notation [was: Re: How to calculate/process this one?]
  • From: has <email@hidden>
  • Date: Sat, 27 Apr 2002 23:03:27 +0100

Arthur J Knapp wrote:

> I would strongly recomend that you steal, oh, er, I mean *borrow* the
>very robust numToStr() handler from ScriptBuilders:


"Robust"? Bah...

set AppleScript's text item delimiters to "foo"
numToStr(1)
--> "1foofoo"

:p

Might warm the pot, but does he remember to put the tea in after? (Nigel,
I'm most ashamed of you!:)

has

======================================================================

-------
--mark private stuff<B

on _getZeros() -- make a 1024-character string filled with zeros
set str to "00000000"
repeat 7 times
set str to str & str
end repeat
str
end _getZeros

property _zeros : _getZeros()

--mark -
-------
--mark public handlers<B

on realToString(theReal)
try
tell theReal as real as string
if it does not contain "E" then
if it mod 1 is 0 then return it as integer as string
return it as string
end if
--
set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "E"
set num to its first character & its text 3 thru first text
[NO-BREAK]item
set pwr to 1 + (its last text item)
set AppleScript's text item delimiters to oldTID
end tell
--
if pwr is greater than 0 then
if num's length is less than pwr then
num & _zeros's text 1 thru (pwr - (num's length))
else if num's length is pwr then
num
else
num's text 1 thru pwr & "." & num's text (pwr + 1) thru -1
end if
else
"0." & _zeros's text 1 thru -pwr & num
if result's last character is "0" then
result's text 1 thru -2
else
result
end if
end if
on error eMsg number eNum
error "Couldn't convert real to string: " & eMsg number eNum
end try
end realToString

======================================================================
[formatted using ScriptToEmail - gentle relief for mailing list pains]
[http://files.macscripter.net/ScriptBuilders/ScriptTools/ScriptToEmail.hqx]

--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Reco Label Stringer
  • Next by Date: Re: Satimage re_compile regex functions
  • Previous by thread: Re: Exponential notation [was: Re: How to calculate/process this one?]
  • Next by thread: Re: Exponential notation [was: Re: How to calculate/process this one?]
  • Index(es):
    • Date
    • Thread