Hello Raymond:
Here is an AppleScript I use to calculate an European date. If you can pack
this into 10 lines I will take off my hat to you.
I believe any significant project will contain many scripts longer than 10
lines. Given that I imagine a project filled with scripts broken into 10
line units could eventually become a maintenance nightmare. Supporting such
a monster would be like trying to understand the logic of a monolithic
Basic program filled with GOTO statements.
"Geoff Canyon" <[EMAIL PROTECTED]> remarked recently that, "One way
to make a comparison between two environments clear is to think of a very
simple project (no more than a few hours' worth of effort) and create it in
both environments."
But of course a very simple project isn't a significant test of an IDEs
capabilities. The interesting question is how REV will behave in a very
complicated project. Unfortunately, the evaluation version with it's 10
line script limit will not allow us to explore more complicated work
(without extraordinary effort).
DW
**********
set theDate to current date
property Y : ""
property M : ""
property D : ""
property leapYear_Y : false
property leapYear_Yminus1 : false
property theEuroDate : ""
--1 GET THE DATE ITEMS
--day number with leading zero
set D to text -2 thru -1 of ("0" & theDate's day)
--month number with leading zero
copy theDate to b
set month of b to January
set M to text -2 thru -1 of ("0" & (1 + (theDate - b + 1314864) div 2629728))
-- make the string
set Y to text -4 thru -1 of ((year of theDate) as text)
--2 FIND IF Y IS A LEAPYEAR
if ((Y mod 4 = 0) and (Y mod 100 � 0)) or Y mod 400 = 0 then set leapYear_Y
to true
--3 FIND IF Y-1 IS A LEAPYEAR
if ((Y mod 4 = 0) and (Y mod 100 � 0)) or Y mod 400 = 0 then set
leapYear_Yminus1 to true
--4 FIND THE DayOfYearNumber for Y, M and D
set mnthNum to {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}
set mm to M as integer --strip the leading zero for the test
if (mm < 1) or (mm > 12) then
error "Out of Range" number 20001
else
set DayOfYearNumber to D + (item M of mnthNum)
end if
if leapYear_Y and M > 2 then set DayOfYearNumber to DayOfYearNumber + 1
--5 FIND THE Jan1Weekday for Y (Monday=1, Sunday=7)
set yy to (Y - 1) mod 100
set C to (Y - 1) - yy
set g to yy + yy / 4
set Jan1Weekday to 1 + (((((C / 100) mod 4) * 5) + g) mod 7)
--6 Find the Weekday for Y M D
set H to DayOfYearNumber + (Jan1Weekday - 1)
set dayOfWeek to 1 + ((H - 1) mod 7)
--7 Find if Y M D falls in YearNumber Y-1, WeekNumber 52 or 53
if (DayOfYearNumber � (8 - Jan1Weekday)) and (Jan1Weekday > 4) then
set YearNumber to Y - 1
if (Jan1Weekday = 5) or ((Jan1Weekday = 6) and leapYear_Yminus1) then
set weekNumber to 53
else
set weekNumber to 52
end if
else
set YearNumber to Y
end if
--8 Find if Y M D falls in YearNumber Y+1, WeekNumber 1
if YearNumber = Y then
if leapYear_Y then
set I to 366
else
set I to 365
end if
if (I - DayOfYearNumber) < (4 - dayOfWeek) then
set YearNumber to Y + 1
set weekNumber to 1
end if
end if
--9 Find if Y M D falls in YearNumber Y, WeekNumber 1 through 53
if YearNumber = Y then
set J to DayOfYearNumber + (7 - dayOfWeek) + (Jan1Weekday - 1)
set weekNumber to J div 7
if Jan1Weekday > 4 then
set weekNumber to weekNumber - 1
end if
end if
--10 Output ISO Week Date
if weekNumber < 10 then
set weekNumber to "0" & weekNumber --(WeekNumber requires 2 digits)
end if
--(Optional: "W" & WeekNumber)
set theEuroDate to YearNumber & "-W" & weekNumber & "-" & dayOfWeek
**********