Next / Previous PopUp Button Entries

never seem to have much luck getting help on forums but I am going to give this a shot as I have been at this one task all day! I have a popup button that gets populated with folder names.

I have a bit of code that goes through the folders and selects one at random. But what I am having trouble is figuring out how to get it to go one folder back or one forward.

For example, if the popup button is showing folder “C”, what code would I use to get it to go to folder “B” and also to folder “D”?

This is the code I am using now for the Random feature… in case it helps:


if which is "randomFolder" then 
   tell window "main" 
      set VarA to (item (random number from 1 to (count of myFolders)) of myFolders) 
      set (current menu item of popup button "folderList") to (first menu item of popup button "folderList" whose title is VarA) 
      set folder_name to title of current menu item of popup button "folderList"
   end tell 
end if 

If anyone out there could help me in any way it would be awesome. Like I said, I have been working on this all day now.

VarA is probably an alias to a folder depending on what is in myFolders
how about:

set VarA to name of (item (random number from 1 to (count of myFolders)) of myFolders) 
set folderCount to count of myFolders
set randomNumber to random number from 1 to folderCount
set prevNumber to randomNumber - 1
set nextNumber to randomNumber + 1

if 1 = randomNumber then set prevNumber to folderCount
if folderCount = randomNumber then set nextNumber to 1

--- now define the folders
set varA to name of (item prevNumber of myFolders)
set varB to name of (item randomNumber of myFolders)
set varC to name of (item nextNumber of myFolders)

I have the feeling that this is not what you meant, maybe that is why no one helped earlier.