• 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: Avoiding repetition
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Avoiding repetition


  • Subject: Re: Avoiding repetition
  • From: Nigel Garvey <email@hidden>
  • Date: Fri, 16 Jul 2004 15:01:17 +0100

In my message of Fri, 16 Jul 2004 10:52:03 +0100, I wrote:

>Bernard Azancot wrote on Thu, 15 Jul 2004 21:14:43 +0200:
>>If myday = Monday then
>>action to folder A
>>
>>else If myday = Tuesday then
>>action to folder B
>>...
>>...

>>Is there a way to avoid repeating 7 times the same boring code lines
>>with 2 bound variables (day and folder) ?
>
>Presumably, you're getting the weekday from the current date. If that's the
>case, you could do something like this instead:
>
> set now to (current date)
> set i to (now - (now - (date "Monday, 1 January 2001 00:00:00")) div
>weeks * weeks)'s day
> set folderName to item i of {"A", "B", "C", "D", "E", "F", "G"}
> myAction(folderName)

Sorry. If I'd been awake, I'd have simplified that to:

set now to (current date)
set i to (now - (date "Monday, 6 January 1000 00:00:00")) mod weeks div
days + 1
set folderName to item i of {"A", "B", "C", "D", "E", "F", "G"}
myAction(folderName)

... or of course:

set folderName to item (((current date) - (date "Monday, 6 January 1000
00:00:00")) mod weeks div days + 1) of {"A", "B", "C", "D", "E", "F", "G"}
myAction(folderName)

:-)

NG
_______________________________________________
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.


  • Follow-Ups:
    • Re: Avoiding repetition
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: Avoiding repetition
  • Next by Date: Re: Avoiding repetition
  • Previous by thread: Re: Avoiding repetition
  • Next by thread: Re: Avoiding repetition
  • Index(es):
    • Date
    • Thread