• 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: *Very* strange script / global variable behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: *Very* strange script / global variable behavior


  • Subject: Re: *Very* strange script / global variable behavior
  • From: has <email@hidden>
  • Date: Tue, 1 Mar 2005 12:45:45 +0000

Neil Faiman wrote:

The context for this is an ASS application where I'm setting the behavior of controls with generic handlers like

	on clicked theButton
		run (get the script of theButton)
	end

and then attaching a script object to each button that specifies the specific behavior for that button. As with any ASS application, the big trick is getting communication right between the various pieces of the script.

It's best if you approach Studio on its own terms rather than trying to make it behave like FaceSpan, which is not something it's designed to do. Even though it's not the most elegant environment you can still write very clean, well-structured code in it. Writing big long conditionals to re-despatch GUI events to individual handlers may seem a bit tedious, but it's completely straightforward and reliable and will easily give you the level of organisation you want:


	on clicked theButton
		if theButton's name is "OK" then
			proceed(theButton)
		else if theButton's name is "Cancel" then
			cancel(theButton)
		[...]
	end clicked

Group all this muck together in the one place separate from the rest of your code and just ignore it thereafter. It's simply not worth trying to be any more clever.


So far, I'm spending about 90% of my time figuring out why my clever solutions don't work.

Nine times out of ten, the dumb, simple solution is the right one. Being overly clever is a common mistake in programming. To quote the mighty Brian Kernighan: "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."


has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
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


  • Prev by Date: Re: Removing html tags
  • Next by Date: going from eudora to Mail
  • Previous by thread: Re: *Very* strange script / global variable behavior
  • Next by thread: Re: *Very* strange script / global variable behavior
  • Index(es):
    • Date
    • Thread