Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text Field Troubles



Here is a comparison of the script that works.  I have coloured in the changes that I think will solve your problem in red:

using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track as string
set cur_artist to the artist of the current track as string
else
set cur_song to ""
set cur_artist to "No song currently playing."
end if
end tell
end using terms from

Peter

On 29/09/2006, at 1:52 PM, Emory Dunn wrote:

Well here is is:

using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track
set cur_artist to the artist of the current track
else
set cur_song to ""
set cur_artist to "No song currently playing."
end if
end tell
end using terms from

(*tell window "tunecommand"
set the contents of text field "title" of window "tunecommand" to cur_song
set the contents of text field "artist" of window "tunecommand" to cur_artist
end clicked*)

set the contents of text field "title" of window "tunecommand" to cur_song
set the contents of text field "artist" of window "tunecommand" to cur_artist
end



Emory


On Sep 28, 2006, at 10:48 PM, Peter Baxter wrote:

Can you post a copy of your script as it is after you removed the tell window statements and replaced them with the statements below?
ie.  
set the contents of text field "title" of window "tunecommand" to cur_song
set the contents of text field "artist" of window "tunecommand" to cur_artist

Peter

On 29/09/2006, at 11:28 AM, Emory Dunn wrote:

Yes, I have tried it while a song was playing. And thats not the problem- its the darned error message saying I can have a double quote after the text field identifier.


Emory


On Sep 28, 2006, at 7:28 PM, Peter Baxter wrote:

Did you try it with a song playing in iTunes?  The current song needs to have iTunes running and a song currently selected.  I currently have a very similar script under construction that works for the data you are calling, but I have not got the section of my script that deals with inserting the artwork going.  The script I supplied you works perfectly in that application.  Do you have your fields set as NSTextFields?  Are they set editable in the options?  Did you try running the script in AS outside XCode?
 
Here is a copy of the similar script I am doing.  Perhaps you can spot an error in yours.  Ignore the artwork bits of the script.

on clicked theObject
if name of theObject is "Button" then
using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track as string
set cur_artist to the artist of the current track as string
--if exists then
--set artworkData to artwork of the current track
--end if
else
set cur_song to ""
set cur_artist to "No song currently playing."
end if
end tell
end using terms from

set the contents of text field "title" of window "tunecommand" to cur_song
set the contents of text field "artist" of window "tunecommand" to cur_artist
--set the contents of image "artworkData" of window "tunecommand" to artworkData  Ignore the next section
else
using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set artworkData to artwork of the current track
else
set artworkData to ""
end if
end tell
end using terms from
end if
end clicked


On 29/09/2006, at 8:50 AM, Emory Dunn wrote:



Well, that did not work. Script Editor is just not getting the fact that they whole script is correct, its just being fussy about something.


Emory


On Sep 28, 2006, at 8:06 AM, Peter Baxter wrote:

Hi Emory.

Your script is OK, but should read

on clicked theObject
using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track as string
set cur_artist to the artist of the current track as string
else
set cur_song to ""
set cur_artist to "No song currently playing."
end if
end tell
end using terms from

--delete tell window "tunecommand"

set the contents of text field "title" of window "tunecommand" to cur_song
set the contents of text field "artist" of window "tunecommand" to cur_artist
--delete end tell
end clicked

On 28/09/2006, at 3:17 PM, Emory Dunn wrote:

I am new to Applscript studio and am writing a basic iTunes controller. I have got most of it working but I can not set the track name and artist info. I  have looked at several places for help- the XCode documentation and other websites and as far as I can tell am doing everything correctly but whenever I try and save the .scpt file it says A “ can't go after this identifier. the script I have written is as follows: the problem areas in red.

using terms from application "iTunes"
tell application "iTunes"
if exists (database ID of current track) then
set cur_song to the name of the current track
set cur_artist to the artist of the current track
else
set cur_song to ""
set cur_artist to "No song currently playing."
end if
end tell
end using terms from

tell window "tunecommand"
set the contents of text field "title" to cur_song
set the contents of text field "artist" to cur_artist
end tell



Emory C. Dunn


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden







 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >Text Field Troubles (From: Emory Dunn <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.