• 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: Does "rounding" work in OS 9.2.1
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does "rounding" work in OS 9.2.1


  • Subject: Re: Does "rounding" work in OS 9.2.1
  • From: Christopher Nebel <email@hidden>
  • Date: Wed, 31 Oct 2001 15:48:08 -0800

On Wednesday, October 31, 2001, at 10:11 AM, email@hidden wrote:

I'm putting together a little script to add selection sizes in the Finder. I
just need a rounded integer for the size. I can't get the rounding script
addition to work. It is in there that I checked. This compiles fine.

set theSizeTotal to 0
tell application "Finder"
activate
set theSelections to every item of selection
repeat with theItem in theSelections
set itemSize to size of theItem
set itemSize to (itemSize / 1024 / 1024)
set theSizeTotal to (theSizeTotal + itemSize)
end repeat
round theSizeTotal rounding as taught in school
display dialog theSizeTotal - I would like this to end up an integer
end tell

The problem is that "round" doesn't do quite what you think it does. It doesn't modify the variable you give it, it just returns the rounded number as a result, so what your script does is ask for the rounded value of theSizeTotal and then throw away the answer.

Change the "round" line to read "set theSizeTotal to round theSizeTotal rounding as taught in school" and it'll be fine. (Your other solution, rounding itemSize, produces less accurate results.)


--Chris Nebel
AppleScript Engineering


  • Prev by Date: Re: applescript-users digest, Vol 2 #1258 - 12 msgs
  • Next by Date: Re: Scripting Canto Cumulus 5.010
  • Previous by thread: RE: Does "rounding" work in OS 9.2.1
  • Next by thread: Re: Does "rounding" work in OS 9.2.1
  • Index(es):
    • Date
    • Thread