"get size" acts like "get font size"?

The following sequence retrieves the width and height of the window, e.g., {625,647}.


tell application "Terminal"
	tell front window
		get size
	end tell
end tell

But this sequence, which uses a variable in place of “Terminal”, returns the font size:


set appname to "Terminal"
tell application appname
	tell front window
		get size
	end tell
end tell

Can anyone explain this behavior?

Thanks in advance,
Alex

Model: macbook pro
AppleScript: applescript 2.0.1, scripteditor 2.2.1
Browser: Firefox 3.0.5
Operating System: Mac OS X (10.5)

Hi,

AppleScript can only resolve the terminology of a particular application,
if this application is specified with the keyword application and a literal string like

tell application "Terminal"

To resolve an application’s terminology specified by a variable use a using terms from block


set appname to "Terminal"
using terms from application "Terminal"
	tell application appname
		tell front window
			get size
		end tell
	end tell
end using terms from

Thanks!

And now for a followup:) Why doesn’t this:


tell application "Terminal"
	get size of front window
end tell

Return the same result as this?


get size of front window of application "Terminal"

The former returns the window size, the latter returns the font size.

I’m guessing it’s the same problem – the terminology can’t be resolved because the context of “Terminal” is lost by the time the result from “front window” is returned. If I encapsulate the second example above with ‘using terms from app “Terminal”’ I do indeed get the window size.

I view this as a serious limitation to the language because the code must explicitly state the full specifier of each object in order to reliably query it. I think this means I can’t write a generic method to operate on any window independent of the application to which it belongs.

Am I missing something?

It seems to me that if I have a handle on an object, say a window, I should be able to get its size without having to specify that it’s a Terminal window.

Thanks in advance,
Alex

terminology will only be resolved, if the code is in a application tell block, the of form doesn’t work
But you can use a tell command also in an one-liner


tell application "Terminal" to get size of front window

A window belongs always to an application respectively to an application process