Same code, different results? xCode and script editor

am trying to write an iTunes script with a user interface through xCode

The problem I am having is that this code behaves differently between xCode and applescript?


tell application "iTunes" 
set whatyadoing to player state as text 
end tell 
display dialog "Info : " & whatyadoing

in script editor I get a nice, “playing”, “paused” etc,
in xcode im getting “<<constant ****kPSp>>”

My question is why is this? and how can I get the easy to read result like in the script editor?

From reading through the documentation it looks like xcode can’t reach the nescessary information from iTunes to make sense of the data iTunes gives it, do I need to set up some sort of link so that xCode knows where to get the info? Am I doing something foolishly wrong? Or is my installation of xCode misbehaving. My worry is if I make my applcation do comparisons on the double chevron code, its going to be harder to read and I am worried that if I find some link I need to make I will need to change my code later. I would also like to be able to pass the descriptive values back to the user without having to interprit what they mean.

Thanks, dave

Yeah, I’m seeing the same results you are. Sometimes Xcode just acts wonky. It is returning the raw Apple Event code instead of the more readable English, don’t know why. Here’s a kludgy fix:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thankyou, looks like that is what I need.

I just found that it will switch into giving human readable results, on the second or third click of the button! But only if I ask for track info in the same tell???

This is annoying as it means that for a while after loading the program could get very buggy, Hopefully when I try your fix it will be working right from when the program starts, I will let you know after I try it tommorow night.

:smiley:

Im glad its not something fundamental im missing.
cheers,
dave