• 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: Michelle Steiner <email@hidden>
  • Date: Thu, 15 Jul 2004 13:08:30 -0700

On Jul 15, 2004, at 12:14 PM, Bernard Azancot wrote:

> Is there a way to avoid repeating 7 times the same boring code lines
> with 2 bound variables (day and folder) ?

Put the action in a handler, and send it the variables.

set myDay to Wednesday

set dayList to {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
Sunday}
set folderList to {FolderA, FolderB, FolderC, FolderD, FolderE,
FolderF, FolderG}
repeat with i from 1 to 7
if item i of dayList is myDay then
set actionFolder to item i of folderList
exit repeat
end if
end repeat

my action(myDay, actionFolder)

on action(theDay, theFolder)
-- do something
end action

--
"Beware the march of ideas."

[demime 0.98b removed an attachment of type application/pgp-signature which had a name of PGP.sig]
_______________________________________________
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.


References: 
 >Avoiding repetition (From: Bernard Azancot <email@hidden>)

  • Prev by Date: Re: Photostitch Dictionary
  • Next by Date: ScriptMenu error
  • Previous by thread: Re: Avoiding repetition
  • Next by thread: Re: Avoiding repetition
  • Index(es):
    • Date
    • Thread