I’m not new to Applescript (1 1/2 years experience) but totally new to Xcode and Applescript Studio (1 month experience)
So I started a useless Application which controls iTunes to learn Xcode.
I call the App “iTunes Remote”.
After a short period I understood the syntax of Applescript Studio. Everything worked fine, until…
I found a bug in my Application. I made my Application look like that:
edit: lol? why do I get linked to a woman posing in front of a scary movie ad? /edit
(I got UNO installed so don’t wonder about the grey color)
I wanted the PlayPause Button to change to Play when iTunes is paused, or to Pause when iTunes is playing.
So I added a “if” which gets started when the PlayPause button is getting pressed.
It looks like this:
tell application "iTunes" to set player_state to player state as string if player_state is "playing" then tell application "iTunes" pause end tell else if player_state is "paused" then tell application "iTunes" to play end if
player_state is made a global var at the beginning of the script.
I know that that doesn’t change the title of the button, but it should Play/Pause iTunes already
Then I have another Problem: I want to check the title of the RepeatButton to Off/One/All reliable to the state of iTunes:
on readitunes() --shuffle state: tell application "iTunes" to set shuffle_set to (shuffle of (current playlist)) as boolean --repeat state tell application "iTunes" to set repeatset to (song repeat of (current playlist)) as string --volume: tell application "iTunes" to set cur_vol to (sound volume) end readitunes on setGUI() --fÃ¼r shuffle: set contents of button "shuffle" of window "main" to shuffle_set --fÃ¼r volume: set contents of slider "volumeslider" of window "main" to cur_vol --fÃ¼r repeat: if repeatset is "off" then set title of button "repeat" of window "main" to "Off" else if repeatset is "one" then set title of button "repeat" of window "main" to "One" else if repeatset is "all" then set title of button "repeat" of window "main" to "All" end if end setGUI
readitunes() and setGUI() are recalled in the “on launched theObject” handler.
the variables are made global at the beginning of the script.
In the “normal” script editor (shipped with the original system Installation) that works so fine.
In Xcode it doesn’t.
The strange is, that the setting of the volume (look above) does work.
So i thought: “Damned, where did I do the mistake?”
I searched like a nerd…and then I noticed that EVERYTHING works fine if I run that App in debug mode inside of Xcode.
Everything works the way I want it to.
So I’m very confused why it doesn’t work in normal way.
Could it be, that that is a bug made by Apple and the compiler? I think so.
If you think that it isn’t a bug, could you please help me? That would be very kind of you.
If needed I can post more sourcecode.
Model: PowerMac G4
AppleScript: Xcode: 2.4.1 Applescript: 1.10.7
Browser: Safari 522.12.1
Operating System: Mac OS X (10.4)