 |
 |
AppleScript Studio Question
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status:
Offline
|
|
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 ...

|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
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
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status:
Offline
|
|
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?

|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status:
Offline
|
|
Can you:
tell me
activate
end tell
?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status:
Offline
|
|
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 ]
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jul 2000
Location: Washington, DC
Status:
Offline
|
|
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
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|