Re: simplify this script
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