Re: How to do a goto with Applescript?
Re: How to do a goto with Applescript?
- Subject: Re: How to do a goto with Applescript?
- From: Alex Zavatone <email@hidden>
- Date: Tue, 11 Jan 2011 21:24:40 -0600
On Jan 11, 2011, at 3:30 PM, Skeeve wrote:
> Am 10.01.11 19:01, schrieb Robert Poland:
>> Please be kind with your remarks.
> No remarks but maybe this pattern helps?
>
> I have a set of prepare_PROGRAMNAME handlers.
>
> Each of those returns a script having a process() handler.
>
> Each of the prepare_PRGRAMNAME handlers' values is associated to a programname in a list of records like this:
> { nme: "Finder", hdlr: prepare_Finder() }
>
> When you have a programname, you compare it to each of the "nme" items in the list. Having found a match you execute the "hdlr" item's process() of the found match.
>
> This way you simply need to
> a) add a new prepare_PROGRAMNAME for each new program
> b) specify what process() needs to do
> c) add an entry in the "programs" list
> -----------------------------------
> on run
> -- list of known programs
> set programs to {{nme:"Finder", hdlr:prepare_Finder()}, ¬
> {nme:"Acrobat", hdlr:prepare_Acrobat()}, ¬
> {nme:"Mail", hdlr:prepare_Mail()}}
This is EXACTLY what I was thinking about.
You know the application you care about at the outset and you know the task you would want to accomplish as well.
Since you have those known important bits, why not declare a handler for each task and use a look up table of "application/task to be executed" where you pull that record from the list and do, call, or run that handler.
You get away from a nasty if statement with conditionals inside where if you break it in one part, you're likely to break it all.
In this case, if you break something within a specific handler, then only stuff for Mail or the Finder is broken.
This assumes that you don't want to do multiple things within each app. But that can be structured properly as well. _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden