• 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: simplify this script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simplify this script


  • Subject: Re: simplify this script
  • From: Emmanuel <email@hidden>
  • Date: Tue, 14 Dec 2004 16:53:33 +0100

At 3:27 PM +0100 14/12/04, Jan-Bultereys wrote:

Can someone help me to simplify this script.....
Look at block 2 .... it's just the same as block 1 but it is pointing to a folder called "2" instead of "1"

What you may be missing is "procedural programming". That is, you declare a handler with the "on" keyword, and you declare arguments to the handler, separated with comma, and in the handler you use the arguments of the handler as local variables. Example:


on DisplayMessage(theMessage, theButton)
display dialog theMessage buttons {theButton} default button 1
end DisplayMessage

Now your script can call that handler, yet providing various parameters to it:

DisplayMessage("Everything is just fine.","Great, thanks")

[...]

DisplayMessage("You got mail.","OK")

[...]

DisplayMessage("Your computer is on fire.","Rats")

[...]

Logically, as soon as you recognize the same block twice, you identify the parameters which may change, and you encapsulate the commands within a handler ("on blah ... end blah"), and those parameters which may change you pass as the arguments to the handler.

Emmanuel

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >simplify this script (From: "Jan-Bultereys" <email@hidden>)

  • Prev by Date: Re: [ANN] XNetwork 1.0
  • Next by Date: Re: [ANN] XNetwork 1.0
  • Previous by thread: simplify this script
  • Next by thread: Re: simplify this script
  • Index(es):
    • Date
    • Thread