Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript: Array Help

I'm trying to create an empty array and then push items into it. I want to take the next 7 days and load them into an array

I have the code to find the next day of current date, and I willl put that into a repeat while loop, creating the next days.

Just not sure on how to tell the script to properly push into an arraY


set thearray to {}

I figure this will give me an empty array. I'm having trouble finding the code (that works) to put them into the array


Can anybody give help?

Posted on May 20, 2011 3:02 PM

Reply
Question marked as Best reply

Posted on May 20, 2011 4:01 PM

Hi,


You add an item to the end of an array like this:


set end of theArray to thisDate


Best wishes


John M

6 replies

May 20, 2011 5:01 PM in response to John Maisey

Thanks!!!! That was easier than it looked, I was looking a more complicated code on the net. I have another issue I built the array and fed the array into a popup button now I'm trying to select a specific menu item (as a default selection, instead of the first or last one)


tell menu of popup button 3


deleteevery menu item

repeat with dateitem in pubdate

make new menu item at beginning of menu items with properties {title:dateitem}


endrepeat

set current menu item to menu item 3


endtell


the set current menu item to menu item 3 gives me an error, Other examples I found are similar

I cant seem to figure out the error.....Anbody have the solution (and why it worked)

May 21, 2011 12:17 AM in response to Jon Lopiano

Hi Jon,


I can't test this bit of Applescript Studio code now, but try this:


tell menu of popup button 3
   delete every menu item
      repeat with dateitem in pubdate
         make new menu item at beginning of menu items with properties {title:dateitem}
      end repeat
end tell
tell popup button 3
   set current menu item to menu item 3
end tell


The current menu item is a property of the popup button and not the popup button's menu (if that makes any sense).


Best wishes

John M

Applescript: Array Help

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.