Support
All support resources for our products. Here you can find answers to frequently asked questions, discuss with other users, recover a lost license code or file a support request.
Forum closed
This forum was closed and turned into an archive effective April 21, 2018. It is no longer possible to create new topics or reply to existing topics.

Thanks everyone for all the great questions and contributions over the years.

Please use the Contact form to get in touch.

Remote Buddy Forum

Overview 

AuthorThread
User

10.05.2007 07:14:23
Re: arrays

This posting is older than 6 months and can contain outdated information.
Whoa, arrays. See, now we're getting beyond my Applescript expertise. I see that it might be possible to piece together a large, complex array from various bits of dynamically-created information, and in the end you'd have a single multilayered menu. It would be very complex though, and to try it would be a major undertaking... maybe one of these weekends.

What I was trying to do instead, is have successive menus, passing the result of one to the next. I actually got this working externally, but can't seem to attach it to a button as a RB action. Here's an example:

Global menu_choice, playlist_list, playlist_choice 
tell application "remote buddy" 
. showmenu with items {1, "choose a playlist", 2, "void", 3, "void #2"} menu name "Main Menu" with return value 
. set menu_choice to result 
end tell 
if menu_choice is 1 then 
. tell application "itunes" 
. . set _playlists to (get name of user playlists) 
. . set playlist_list to {} 
. . repeat with _playlist in _playlists 
. . . if playlist does not contain _playlist then 
. . . . set playlist_list to playlist_list & _playlist & _playlist 
. . . end if 
. . end repeat 
. end tell 
. tell application "remote buddy" 
. . showmenu with items playlist_list menu name "pick a playlist" with return value 
. . set playlist_choice to result 
. end tell 
. tell application "itunes" 
. . activate 
. . set playlist_choice to (playlist_choice as string) 
. . set view of browser window 1 to playlist playlist_choice 
. . play playlist playlist_choice 
. end tell 
else if menu_choice is 2 then 
. return 
else if menu_choice is 3 then 
. return 
end if

Paste that into a Script Editor window and press 'run' and it will successfully take you through two successive RB-style menus, and culminate with iTunes playing the playlist you choose.

But paste that into the Applescript box of a custom action assigned to a button in Remote Buddy, and it doesn't work. It compiles successfully, but after the first menu disappears the script stalls and no other menus appear. I don't know if it hangs while trying to process the iTunes command to get all user playlists,or while trying to move the global variables between the command for the different applications... but it hangs on something.

I tried saving the script as a run-only application and having RB open it (with an Applescript such as 'tell application "Finder" to open application "menu script"') and the whole system gets bogged down.

So, can we not do successive 'showmenu' commands in Applescripts executed by RB? Is the only recourse to generate a single, massive 'showmenu' array and call it once?

Edit: 
[If you're curious why I added each playlist twice to playlist_list, it's because of the way RB handles showmenu arrays. Each menu item has a first value (here 1, 2 and 3) that is used by RB to process the menu choice, and a second value (here "choose a playlist", "void" and "void #2") that is actually displayed in the menu. By adding two instances of each playlist these two values become identical, and it becomes easy to pass the values along to successive menus.]

Last edited: 10.05.2007 07:20:07 

Thread-display::