Re: Does "rounding" work in OS 9.2.1
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