Monday, November 08, 2010 at 12:04 AM.
system.verbs.builtins.mainResponder.calendar.getMostRecentAddress
on getMostRecentAddress (adrCalendar, d=clock.now ()) {
<<Tue, May 23, 2000 at 5:44:42 PM by AR
<<Old code
<<on getMostRecentAddress (adrCalendar, d=clock.now ())
<<Notes
<<Thu, 11 Mar 1999 20:00:22 GMT by AR
<<adrcalendar is the address of a valid calendar structure.
<<d is an optional date which defaults to clock.now ().
<<If the address corresponding to d exists, we return it.
<<Otherwise we walk backwards in time until we find an element and return its address.
<<We throw a scriptError if the calendar does not contain elements corresponding to times before d or if adrcalendar does not point to a valid non-empty calendar structure.
<<local (adrDay, dmin = mainResponder.calendar.getFirstDay (adrCalendar))
<<while (dmin <= d)
<<try
<<adrDay = mainResponder.calendar.getDayAddress (adrCalendar, d, flcreate:false)
<<if defined (adrDay^)
<<return (adrDay)
<<d = date.yesterday (d)
<<scripterror ("Can't get the most recent address in the calendar because the calendar doesn't contain any elements before " + d + ".")
kernel (mrcalendar.getmostrecentaddress)}
<<bundle //test code
<<dialog.notify (getMostRecentAddress (@scriptingNews))
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.