Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AppleScript parsing things it shouldn't

AppleScript parsing things it shouldn't
Thread Tools
Grizzled Veteran
Join Date: Jun 2001
Status: Offline
Reply With Quote
Mar 13, 2005, 03:12 AM
 
I really don't like AppleScript. I need my {'s and ;'s to program.

However, I'm trying to make a simple script that can log my current iTunes track info to a file. I've got the logging part down, but things start breaking when non-alphanumerical characters enter the picture. For instance, the following script tells me "iTunes got an error: sh: line 1: Union: command not found" when I play a track by Alison Krauss & Union Station and run this. Why on earch is it trying to handle the contents of a string as AppleScript code? That's just crazy. I've tried putting string() around the_artist, but now I'm just guessing (like I wasn't before, hah).

Yes, I'm aware that this is rather ugly.

Code:
tell application "System Events" if ((application processes whose (name is equal to "iTunes")) count) is greater than 0 then tell application "iTunes" if player state is playing then set the_artist to artist of current track set the_song to name of current track set the_album to album of current track if the_artist is not missing value then if the_album is not missing value then if the_song is not missing value then do shell script "echo " & the_artist 'and other stuff end if end if end if end if end tell end if end tell

Thanks!
     
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Mar 13, 2005, 04:21 AM
 
It's actually the shell trying to parse the string. Try this:

do shell script "echo " & quoted form of the_artist

instead of

do shell script "echo " & the_artist
[Wevah setPostCount:[Wevah postCount] + 1];
     
Grizzled Veteran
Join Date: Jun 2001
Status: Offline
Reply With Quote
Mar 13, 2005, 04:24 AM
 
Ah, thank you!
     
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Mar 13, 2005, 10:37 AM
 
No problem; you're welcome.

[Wevah setPostCount:[Wevah postCount] + 1];
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:14 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2