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 Studio Question

AppleScript Studio Question
Thread Tools
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status: Offline
Reply With Quote
Jan 21, 2002, 03:14 AM
 
I am attempting to get a list of artists in a particular playlist into a variable as a list like {"artist1", "artist2"} etc. After the list is properly constructed (a repeat statement pulls in only unique artists), I attempt to pump it into a popup button. Using the script
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>repeat with i in iTunesList
make new title at end of titles in popup button <font color = red>"theListPopUp"</font> with properties {name: i, enabled: true}
end repeat</font>[/code]
I'm not at my machine at the moment, so I'm not exactly sure about the syntax for the moment, but I know it works how I have it at home. The problem occurs in the menu - every character turns into a menu item, including the brackets, quotes and spaces. How do i change the syntax to pump each list item as a new title of popup button?

One more question: what is "my?" I see it strewn in certain places, like before certain variables. I have never seen this before and I think I should probably know this beore continuing ...


How did it come to this? Goodbye PowerPC. | sensory output
     
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Jan 21, 2002, 11:46 AM
 
Originally posted by krove:
<STRONG>I am attempting to get a list of artists in a particular playlist into a variable as a list like {"artist1", "artist2"} etc. After the list is properly constructed (a repeat statement pulls in only unique artists), I attempt to pump it into a popup button. Using the script
<font face = "courier">repeat with i in iTunesList
make new title at end of titles in popup button "theListPopUp" with properties {name: i, enabled: true}
end repeat</font>
I'm not at my machine at the moment, so I'm not exactly sure about the syntax for the moment, but I know it works how I have it at home. The problem occurs in the menu - every character turns into a menu item, including the brackets, quotes and spaces. How do i change the syntax to pump each list item as a new title of popup button?

One more question: what is "my?" I see it strewn in certain places, like before certain variables. I have never seen this before and I think I should probably know this beore continuing ...

</STRONG>
It should never do that unless your list looks like this: "{\"a\", \"b\"}" etc.. Can you show the part where you define iTunesList?

As for my/me that will refer to the script and will ignore the current tell block. For instance...

set thescript to load script "mac hd:desktop:scriptLib"

tell thescript
display("hello")
my display("went well")
end tell


First you are telling the loaded script.. now "display("hello")" will call the display handler from thescript. "my display("went well")" call the handler from the currently running script.

Another useful way to use this is:

tell application "Finder"
--do some finder stuff
tell me to display dialog "All went all."
end tell

In the above case it would use the finder to do some copying, renaming etc.. and then the applet would display the dialog rather than the Finder as it is something you want your app to report, not the finder.

HTH
     
krove  (op)
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status: Offline
Reply With Quote
Jan 21, 2002, 01:31 PM
 
set iTunesList to "{\""
[code snip]add inner complete with quotes and commas
set iTunesList to iTunesList and "\"}"

So am I right in assuming that \ is not the correct character to use in (forget the word) the quote mark?

I guess I could just as easily insert a \ in between each item to get the end I want (see as how that appears to be the cause of my problem) - but which is better programming?


How did it come to this? Goodbye PowerPC. | sensory output
     
krove  (op)
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status: Offline
Reply With Quote
Jan 21, 2002, 01:33 PM
 
Can you:

tell me
activate
end tell

?

How did it come to this? Goodbye PowerPC. | sensory output
     
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Jan 21, 2002, 06:37 PM
 
Originally posted by krove:
<STRONG>set iTunesList to "{\""
[code snip]add inner complete with quotes and commas
set iTunesList to iTunesList and "\"}"

So am I right in assuming that \ is not the correct character to use in (forget the word) the quote mark?

I guess I could just as easily insert a \ in between each item to get the end I want (see as how that appears to be the cause of my problem) - but which is better programming?

</STRONG>
A standard list should look like this:

{"a", "b", "c", "d", "e", "f", "g"}


If you list looks like just that then it would work. Otherwise I cannot really help until I see where you defined iTunesList (it is hard to understand your example)

Regarding the.. tell me to activate question..

Yes, you can do it, but I don't think it will do much good if it is just a script that is not an applet. But if it is, I believe "activating" the script will make it frontmost.
     
krove  (op)
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status: Offline
Reply With Quote
Jan 22, 2002, 03:16 AM
 
I must have forgotten to mention that I was building an AppleScript Studio application. I wanted to pull all the artists for the tracks in a particular playlist and put them into a popup button.

I wanted it to only list unique artists. I'm fairly certain the algoritm for putting only unique items works, but I don't know how to properly add i to the list iTunesList when I want. (I gave up on the whole adding of quotes - because it is already dealing with list items - I should be able to just add the list item to the end of the list right?)



[ 01-23-2002: Message edited by: krove ]

How did it come to this? Goodbye PowerPC. | sensory output
     
krove  (op)
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status: Offline
Reply With Quote
Jan 23, 2002, 09:48 AM
 
Silly me...lists are way easier. I found an algorithm that actually works and properly places one item for each menu item. The weird parts is you can't say

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>if i is not in iTunesList then
copy i to the end of iTunesList
end if</font>[/code]

I found some examples on the net using and manipulating lists and they stated that one could compare a single item (in this case, my i) to a list (iTunesList). Weird, but I got around it...

Is there a call or algorithm that can alphabetize the items in a list?

Kyle

How did it come to this? Goodbye PowerPC. | sensory output
     
   
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:46 PM.
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