Q: Applescript conflict with the iTunes constants 'error' and 'duplicate'
In AppleScript the keyword 'error' is a reserved word. Unfortunately iTunes also defines a constant called 'error used as a possible value for e.g. a track's iCloud status. As a result code such as:
if aTrack's cloud status is equal to purchased then
set tCloudStatus to "purchased"
else if aTrack's cloud status is equal to matched then
set tCloudStatus to "matched"
else if aTrack's cloud status is equal to uploaded then
set tCloudStatus to "uploaded"
else if aTrack's cloud status is equal to ineligible then
set tCloudStatus to "ineligible"
else if aTrack's cloud status is equal to removed then
set tCloudStatus to "removed"
else if aTrack's cloud status is equal to duplicate then
set tCloudStatus to "duplicate"
else if aTrack's cloud status is equal to subscription then
set tCloudStatus to "subscription"
else if aTrack's cloud status is equal to no longer available then
set tCloudStatus to "no longer available"
else if aTrack's cloud status is equal to not uploaded then
set tCloudStatus to "not uploaded"
else if aTrack's cloud status is equal to error then
set tCloudStatus to "error"
else
set tCloudStatus to "unknown"
end if
Fails to even save as it complains about the use of 'error''. There is also a similar problem with 'duplicate' (that is also an AppleScript term).
Does anyone know how I can force the code to use the iTunes meaning of these terms and not the AppleScript meaning? I tried 'using terms from application "iTunes"' but that did not resolve the problem.
Thanks for any pointers...
Chris
if aTrack's cloud
else
set tCloudStatus to "unknown"
end if
Posted on May 29, 2016 1:02 PM
Ah. Yes, that does seem to be broken.
In that case, you'll just need to beat on it the hard way (at least until it gets fixed):
# iTunes 'cloud status' constants: property kPurchased : «constant ****kPur» property kMatched : «constant ****kMat» property kUploaded : «constant ****kUpl» property kIneligible : «constant ****kRej» property kRemoved : «constant ****kRem» property kError : «constant ****kErr» property kDuplicate : «constant ****kDup» property kSubscription : «constant ****kSub» property kNotAvailable : «constant ****kRev» property kNotUploaded : «constant ****kUpP» property kUnknown : «constant ****kUnk» tell application "iTunes" set aTrack to current track -- current track set status to aTrack's cloud status if status = kPurchased then set tCloudStatus to "purchased" else if status = kMatched then set tCloudStatus to "matched" else if status = kUploaded then set tCloudStatus to "uploaded" else if status = kIneligible then set tCloudStatus to "ineligible" else if status = kRemoved then set tCloudStatus to "removed" else if status = kDuplicate then set tCloudStatus to "duplicate" else if status = kSubscription then set tCloudStatus to "subscription" else if status = kNotAvailable then set tCloudStatus to "no longer available" else if status = kNotUploaded then set tCloudStatus to "not uploaded" else if status = kError then set tCloudStatus to "error" else set tCloudStatus to "unknown" end if end tell display dialog tCloudStatus
Posted on May 30, 2016 9:51 AM