• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: assigning properties of an object in a loop, in a tell block
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: assigning properties of an object in a loop, in a tell block


  • Subject: Re: assigning properties of an object in a loop, in a tell block
  • From: Kaydell Leavitt <email@hidden>
  • Date: Sun, 23 Jun 2013 22:12:45 -0600

Hi Alex,

Here's  a new version of the code that I think is closer to what you want to do:

on getOverdueReminders()
tell application "Reminders"
set myFinalList to {}
#get the actual reminders that are not done and should have been done by now
set overdueReminders to reminders whose (completed is false) # and (due date < (current date))
if length of overdueReminders > 0 then #extract all information
repeat with r in overdueReminders
set theProperties to properties of r
set myFinalList to myFinalList & {theProperties}
end repeat
end if
end tell
return myFinalList
end getOverdueReminders

# get the list of overdueReminders from Reminders.app as a list of records
set overdueReminders to getOverdueReminders()

When I run this script, I seem to get what appears to me to be a list of dictionaries (i.e. records)  I think that there are only two
things left to be done (as far as I know)

1. Get the due date working to select only records that are past due
2. Possibly expanding other AppleEvent objects into their properties, using "properties of x" where
x is some object that you want to convert from an object id into the actual data.

-- Kaydell
http://learnmacprogramming.com


On Jun 23, 2013, at 9:40 PM, Kaydell Leavitt <email@hidden> wrote:

Hi Alex,

Yes, that's what I needed, the entire function.  I got it to compile and run and produce some reasonable results, but it's not done yet.  Here is the code back:

on getOverdueReminders()
#I seem to have to do this or I get what seem to be casting errors
set {myName, myPriority, myDueDate, myRemindMeDate, myCreationDate, myModificationDate, myBody, myList} to {0, 0, 0, 0, 0, 0, 0, 0}
set myFinalList to {} #list of records, each record one reminder
tell application "Reminders"
#get the actual reminders that are not done and should have been done by now
set overdueReminders to reminders whose (completed is false) # and (due date < (current date))
if length of overdueReminders > 0 then #extract all information
repeat with r in overdueReminders
set myName to name of r
set myDueDate to due date of r
set myRemindMeDate to remind me date of r
set myCreationDate to creation date of r
set myModificationDate to modification date of r
set myPriority to priority of r
set myB to body of r
set myFinalList to myFinalList & myName & ", "
# set my finalList to my finalList & {name:name, notes:notes, priority:priority, list:list, due_date:dueDate, modification_date:modificationDate, remind_me_date:remindMeDate, creation_date:creationDate}
end repeat
end if
end tell
return myFinalList
end getOverdueReminders
display dialog "Overdue Reminders: " & getOverdueReminders() as text

1. What called my attention to some of the bugs was the syntax coloring.  I believe that all of the variables should be green, etc.
2. I don't believe that the correct value was being returned by the function.  I added the following line of code as the return statement:
return myFinalList

Here's what I know of that is left to be done:

1. Get the "and" working in the "whose" clause.
2. Have "myFinalList" return more than a list of names.

I'll work with it some more.  Let me know if you get a new version of the code.

-- Kaydell

On Jun 23, 2013, at 7:48 PM, Alex Hall <email@hidden> wrote:

on getOverdueReminders()
set rl to {} #stores all the reminders we get
#I seem to have to do this or I get what seem to be casting errors
set {name, priority, dueDate, remindMeDate, creationDate, modificationDate, notes, list} to {0, 0, 0, 0, 0, 0, 0, 0}
set finalList to {} #list of records, each record one reminder
tell application "Reminders"
#get the actual reminders that are not done and should have been done by now
set rl to reminders whose (completed is false) and (due date < (current date))
if length of rl > 0 then #extract all information
repeat with r in rl
set my name to name of r
set my dueDate to due date of r
set my remindMeDate to remind me date of r
set my creationDate to creation date of r
set my modificationDate to modification date of r
set my priority to priority of r
set my notes to body of r
set my finalList to my finalList & {name:name, notes:notes, priority:priority, list:list, due_date:dueDate, modification_date:modificationDate, remind_me_date:remindMeDate, creation_date:creationDate}
end repeat
else #no overdue reminders
return {}
end if
end tell
return rl
end getOverdueReminders
display dialog getOverdueReminders()



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: assigning properties of an object in a loop, in a tell block
      • From: Alex Hall <email@hidden>
References: 
 >assigning properties of an object in a loop, in a tell block (From: Alex Hall <email@hidden>)

  • Prev by Date: assigning properties of an object in a loop, in a tell block
  • Next by Date: Re: assigning properties of an object in a loop, in a tell block
  • Previous by thread: assigning properties of an object in a loop, in a tell block
  • Next by thread: Re: assigning properties of an object in a loop, in a tell block
  • Index(es):
    • Date
    • Thread