Re: Avoiding repetition
Re: Avoiding repetition
- Subject: Re: Avoiding repetition
- From: Nigel Garvey <email@hidden>
- Date: Fri, 16 Jul 2004 10:52:03 +0100
Bernard Azancot wrote on Thu, 15 Jul 2004 21:14:43 +0200:
>
(* Pseudo Script Start *)
>
>
-- Note that "action" is the action performed, always the same
>
(delete/copy), but in a different folder each different day of the week
>
(backup purpose)
>
>
If myday = Monday then
>
action to folder A
>
>
else If myday = Tuesday then
>
action to folder B
>
...
>
...
>
else if myday = Sunday then
>
action to folder G
>
>
(* Pseudo Script End *)
>
>
>
>
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)
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.