📜 ⬆️ ⬇️

Interesting Applescript Behavior

Interesting things gives AppleScript. If, for example, we refer to an object to read its property and then we want to correlate the value of this property with a specific set of values, then we will have to write a type construct
object (property = 1) or (property = 0)
rather obvious
object property = (1 or 0)
I encountered this feature when writing a script that can itself set the value of the equalizer setting, depending on the genre of the song (s). The script looks like this:
--
property EQRock : ""
property EQBlues : "--"

tell application "iTunes"
set EQ of (tracks whose (genre is "Rock") or (genre is "Alternative")) to EQRock
set EQ of (tracks whose genre is "Blues") to EQBlues
end tell

If you write
set EQ of (tracks whose genre is ("Rock" or "Alternative")) to EQRock

then the AppleScript machine will not understand you, although it is written almost in Russian. And even if we change the construction from “or” to the set {...}, then again nothing will work. Such an interesting behavior.

')

Source: https://habr.com/ru/post/72894/


All Articles