Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Days and hours



kai wrote on Thu, 20 Oct 2005 23:12:31 +0100:

>... Of course, if anyone's into using atypical parent properties,
>it might be safer to refer to AppleScript, rather than to the script
>itself:

>property parent : 3 (* Or: {"a", "b"}, October, pi, etc. *)
>tell "1 1 1" to tell (my date it) to it
>--> error number -1728 (errAENoSuchObject): Can't get date "1 1 1" of
>[whatever].

"Hello, list. I've written the above script and it doesn't work. Can
anyone tell me what I'm doing wrong?"  ;-)

>on requiredMonth()
>>     tell "1 1 1" to tell (my date it) + 24 * days to tell {it + ¬
>>         7 * days, date string's words & "1", 1} to considering case
>>         set end to beginning's date string's words
>>         repeat while end's item item 3 is in item 2
>>             set item 3 to (item 3) + 1
>>         end repeat
>>         set end to {item 2's item item 3, end's item item 3}
>>         repeat 10 times
>>             set beginning's day to 32
>>             set end's end to beginning's date string's word item 3
>>         end repeat
>>         its end
>>     end considering
>>     tell (choose from list result) to if it is false then
>>         error number -128
>>     else
>>         my date beginning's month
>>     end if
>end requiredMonth

The above code (by me), while it is to be avoided in its own right, might
not work properly if your word for "January" or "February" is the same as
your word for "Thursday". Fortunately, in western languages, any
coincidence is more likely to affect "March" and "Tuesday", which is no
problem here.  :-)

>on totalHours for m from h
>     tell (current date)
>         set its month to m
>         set day to 28
>         tell {it + 4 * days, its weekday as integer, ((h's item ¬
>             1) + (h's item 2) + (h's item 3) + (h's item 4) + ¬
>             (h's item 5) + (h's item 6) + (h's item 7)) * 4}
>             repeat with d from item 2 to (item 2) + ((beginning - ¬
>                 (beginning's day) * days)'s day) - 29
>                 set last item to end + (h's item (d mod 7 + 1))
>             end repeat
>             its end
>         end tell
>     end tell
>end totalHours
>
>totalHours for requiredMonth() from {0, 2.5, 2.5, 2, 0, 2, 0}

I can imagine Ronnie Barker reciting this at high speed from memory.  :-)

NG

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

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.