Application's name as a variable causes a compilation error

Why this script fails to compile?

property MusicPlayerName :"iTunes"

tell MusicPlayerName
	set {curtrnm, cureqnm} to {(the name of current track), the name of the current EQ preset}
end tell

I need the name stored in a variable.

Model: MacBook Pro 9,1 (mid-2012 15") Core i7 2.3 GHz, 16 GB RAM, 1TB SSD
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14

To be able to evaluate the application’s terminology at compile time the argument of tell application MUST be a constant.

Apart from that

 tell "iTunes"

will never work

There are two possible forms

tell application "iTunes"

or

using terms from application "iTunes"
    tell application variable

In the second form the argument of tell application can be a variable but then using terms from must be a constant.

I accidentally missed “application” in my post but it keeps throwing the error nonetheless. I need to have its name in a variable only as my another script is dependant on that.

AppleScript: 2.7
Browser: Safari 604.1
Operating System: macOS 10.14

Reconsider your design. As I said It’s impossible

Terminologies are different and even if passing the application name in a variable worked (it does not) keywords related to iTunes in a Safari tell block is pointless anyway.

There wasn’t a Safari block but you may be right about the design. What’s weird is that such a simple syntax fails. That’s laughable.

Safari was just an example.

What is the sense of executing current track in an environment which doesn’t understand this statement? Once again almost any terminology is tied to a specific application.

It’s unclear what you are going to accomplish.

Hi,

If you want wrote universal Music & iTunes script, you can use critical code’s text representation. Like this:


-- detect what music app is installed
try
	application id "com.apple.iTunes"
	set MusicPlayerId to "com.apple.iTunes"
on error
	set MusicPlayerId to "com.apple.Music"
end try

-- critical code's text representation
set universalMusicScript to "tell application id \"" & MusicPlayerId & "\"" & linefeed & ¬
	"return {name of current track, name of current EQ preset}
end tell"

-- do script
set {curtrnm, cureqnm} to run script universalMusicScript