Re: Finding the oldest date in a list
Re: Finding the oldest date in a list
- Subject: Re: Finding the oldest date in a list
- From: Nigel Smith <email@hidden>
- Date: Thu, 20 May 2004 17:54:39 +0100
On 18/5/04 21:14, "Steven Valenti" <email@hidden> wrote:
>
I would like to find the oldest date in a list but just can't seem to
>
think how to evaluate all of the items. Can anyone help?
And, just for fun, here's two that use just AppleScript, by munging the
vales into strings that can easily be compared. Watch those linebreaks:
----------
set BackUpFolder to {"5/11/2004", "5/12/2004", "5/13/2004", "5/14/2004",
"5/17/2004", "5/18/2004"}
repeat with eachItem in BackUpFolder
set contents of eachItem to (word 3 of eachItem & "-" & <break>
(text -2 thru -1 of ("0" & word 1 of eachItem)) & "-" & <break>
(text -2 thru -1 of ("0" & word 2 of eachItem)))
end repeat
set baseDate to item 1 of BackUpFolder
repeat with x from 2 to count of BackUpFolder
if item x of BackUpFolder < baseDate then set baseDate to <break>
item x of BackUpFolder
end repeat
return ("" & ((word 2 of baseDate) as integer) & "/" & <break>
((word 3 of baseDate) as integer) & "/" & word 1 of baseDate)
----------
And, in an attempt to win the "Longest line when avoiding Mailserver
problems" award:
----------
set BackUpFolder to {"5/11/2004", "5/12/2004", "5/13/2004", "5/14/2004",
"5/17/2004", "5/18/2004"}
set baseDate to item 1 of BackUpFolder
repeat with x from 2 to count of BackUpFolder
set tmp to item x of BackUpFolder
if ((word 3 of tmp) as integer is not greater than (word 3 of baseDate)
as integer) and ((word 1 of tmp) as integer is not greater than (word 1 of
baseDate) as integer) and ((word 2 of tmp) as integer is not greater than
(word 2 of baseDate) as integer) then set baseDate to tmp
end repeat
return baseDate
----------
:-)
Nigel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.