Syntax for chaining?

My Chrome-script is in the middle of a “tell front window”-statement when I need to count the numbers of windows and send as an argument to another handler in a “oneliner”. Is that possible? Everything I have tried so far returns error messages.

Basically my non-working code is

tell application "Google Chrome"
	tell front window
		myHandler "count: " & (tell application "Google Chrome" to count windows)
	end tell
end tell

The problem is that set winCount to tell application "Google Chrome" to count windows doesn’t work and instead have to be written like this tell application "Google Chrome" to set winCount to count windows.

The code would work if it looked like this

tell application "Google Chrome"
	myHandler "count: " & (count windows)
end tell

but I don’t really understand what the difference is!?

You have a 'tell application “Google Chrome” ’ clause inside of a 'tell application “Google Chrome” ’ clause. You can’t or shoudln’t do that.

if you are trying to set a wincount variable try this…

 tell application "Google Chrome" to set winCount to (count windows)
1 Like

If you want to call a handler from within a tell block, you have to say ‘my handler()’ - two words.

I don’t know if this helps at all, but:

tell application "Google Chrome"
	set winCount to (count windows)
	display dialog ("Window Count: " & winCount)
	tell window 1
		set tabCount to (count tabs)
		display dialog ("Tab Count: " & tabCount)
	end tell	
end tell