floor (1.5001) as integer
There’s a space between “floor” and the parenthesized argument _expression_. If you run this script, the event log reveals:
tell application "Script Editor"
floor 2
--> 2.0
end tell
AppleScript coerced 1.5001 to an integer and then sent it the floor message (which is, of course, what you’re complaining about). If you want to perform the “floor” command before “as”, then you must place it inside the parenthesis
(floor 1.5001) as integer
to produce
tell application "Script Editor"
floor 1.5001
--> 1.0
end tell
If you look at the precedence chart in the ASLG, you’ll see that “as” is an operator, and all the operators have precedence over commands. That way, command argument expressions are fully evaluated before passing them to the command:
The real issue here is that you expect “floor” to have the precedence of some operator, but AppleScript doesn’t know that it behaves as an operator, nor what its precedence would be if it were. If you’d like a means for commands to specify their precedence, please file an enhancement request at <http:bugreport.apple.com>.
--
Chris Page
The other, other AppleScript Chris