Of course. But… “log” is not an inherited property of an image view, so you can’t send it a log command and expect it to know what you want it to do. Always be aware of who is recipient of a command you are sending. NEVER put commands in a tell block that don’t need to be there, even if they seem to compile and/or execute properly. Regardless of how much extra work it creates for you, or how many extra lines of code are necessary, it is bad programming style to send commands without knowing where they are going and without clarifying (even if only to yourself) what the real purpose of the command is. If all you’re doing is grabbing a reference to the image view, you could do this in one line and avoid using a tell block altogether. Otherwise, get your references, do what you need to do, and then exit the tell block and tell the main script object to perform the log command.
on clicked theObject
if name of theObject is "getBounds" then
(* Use references that never use a tell block *)
set theBounds to bounds of image view "imageView" of window "window"
log theBounds
(* Wait until outside the tell blocks to send the log command *)
tell window "window"
tell image view "imageView"
set theBoundsNested to bounds
end tell
end tell
log theBoundsNested
(* Explicitly telling 'me' to do the log command *)
tell window "window"
tell image view "imageView"
set theBoundsAgain to bounds
tell me to log theBoundsAgain
end tell
end tell
end if
end clicked
Another thing to consider, is that you may only be getting this error as part of your development and troubleshooting. I doubt you need to log the bounds as part of your actual implementation, and expect that you’re only doing this to see what the value is during development. If you remove the log line, and instead set the bounds to a variable, I’m guessing all your troubles will go away.
I should have been more forthcoming in my initial post. I did try executing the code without a tell block but kept getting a -1708 error. However, logging outside the tell block worked. And you’re right, the log call won’t be part of the final code I was just checking the variables.