I’ve been away from scripting for quite a long time, so I may have forgotten some intricacies AS. But I hope that someone can explain to me why the following simple thing does not work:
use AppleScript version "2.5" -- El Capitan (10.11) or later
use scripting additions
use framework "Foundation" --for ASObjC
tell application "Numbers"
tell table 1 of sheet 1 of front document
round (get value of cell 4 of row 5)
end tell
end tell
I get the error “Can’t get value of cell 4 of row 5
”.
If I remove the statement use framework "Foundation"
, then I get another error instead: “Can’t get row 5
”.
But if I remove all the use statements, it does work, like a miracle!
Very strange! I thought no ‘use’ statements meant the latest AS and Standard Additions!? Not?
Also, with all the use statements in place, I can get it to work if I put the ‘round’ command on a separate line:
use AppleScript version "2.5" -- El Capitan (10.11) or later
use scripting additions
use framework "Foundation" --for ASObjC
tell application "Numbers"
tell table 1 of sheet 1 of front document
(get value of cell 4 of row 5)
round result
end tell
end tell
So, although I have this workaround, I don’t understand what’s going on, and it is extremely difficult to debug large scripts by random trial and error. I need to understand why certain things will not work.
I do note that ‘round’ comes from Standard Additions, and somehow it seems to clash with something, but Numbers does not have a ‘round’ command.
In theory, one should only have statements in tell blocks that target the app, but in practice, scripts become totally unwieldy if it jumps in and out of a myriad bog of tell statements making the script completely unreadable.