Tell handler - direct and indirect call

Strange. In previous versions of Mac Os I was able to run:


set App to "Script Editor"
tell application App 
 tell document 1
  set pt to path
 end
end

… It doesn’t work anymore. Whereas:

tell application "Script Editor"
 tell document 1
  set pt to path
 end
end

…works of course. Why the same script fails in case 1 ? :rolleyes: :rolleyes: :rolleyes:
A string is a string be it a variable or declared explicitly.

(Sorry for the formatting, was written on my phone)

The previous version of Mac OS was run by luck not by solid code :wink:

To make sure all the code is compiled into the right AppleEvents and to make sure the right dictionary is used while doing that you should use “using terms from”.

set appName to "Script Editor"

using terms from application "Script Editor"
	tell application appName
		tell document 1
			set pt to path
		end tell
	end tell
end using terms from

The example code above should also be used in previous version of Mac OS.

I see!
At some point Apple decided to change Applescript Editor with a generic substitution which isn’t correct. AS Editor would fit better as it’s shorter and not generic.
Maybe it’s just an aesthetic reason to use a variable instead to use a direct call :lol:
Backward compatibility seems no more that easy this days.

I’m not sure if the Applescript Editor was better… In its newer versions - (yose and cap) the compile command causes the document to lose the insertion point and jumps for 2 seconds around like a crazy horse, let’s say from line 100 to line 80 or so. Wasn’t the case in older versions. This happens especially by very long scripts

Maybe this is the time to trash the Script Editor for good.
I’m also very tired of the caveman debugging: Script Debugger or Swift looks less outdated as sad this conclusion is about the vanilla Applescript editor that made us very happy

For backward compatibility Script Editor responds to old app names just fine. No reason to use fancy code there.

AppleScript lies on top of OSA – which is generic – and AppleScript is no more than a dialect (in theory). So getting rid of AppleScript in its name is fine because you can write with Script Editor OSA scripts using either JavaScript or AppleScript syntax. Getting rid of AS or AppleScript in the name is just common sense.

AppleScript becomes more strong with each version, from my experience that’s a good thing. An scripting language that is more consistent than randomly choose whatever it likes when on a crossroad is not the way to go. On MS we call them funny quirks but in reality it just allows bad written code that is doomed to fail in some situations.

Keep in mind that SD doesn’t make you a better coder on any level.