6 Replies Latest reply: May 21, 2011 3:38 PM by John Maisey
Jon Lopiano Level 1 Level 1 (35 points)

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?

  • John Maisey Level 5 Level 5 (6,895 points)

    Hi,

     

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

     

     set end of theArray to thisDate
    

     

    Best wishes

     

    John M

  • Jon Lopiano Level 1 Level 1 (35 points)

    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

      delete every menu item

                                  repeat with dateitem in pubdate

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

      end repeat

                                  set current menu item to menu item 3

      end tell

     

    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)

  • twtwtw Level 5 Level 5 (4,900 points)

    err...  is that AppleScript Studio code?  Just trying to be clear about what you're doing - I don't remember *** well enough to be helpful with it.

  • John Maisey Level 5 Level 5 (6,895 points)

    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

  • Jon Lopiano Level 1 Level 1 (35 points)

    Thanks That worked...I was nesting the sntax in the wrong place, once I saw that it all came together quickly...

    Thanks to you guys my project is pretty much done.

     

               Thanks!!

  • John Maisey Level 5 Level 5 (6,895 points)

    I'm glad it helped.