• 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: Design Report for Scripts?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Design Report for Scripts?


  • Subject: Re: Design Report for Scripts?
  • From: "S. J. Cunningham" <email@hidden>
  • Date: Sat, 21 Nov 2015 04:51:07 -0500

On Nov 21, 2015, at 4:15 AM, Yvan KOENIG wrote:

> Honestly, as I don’t see any interest to this kind of variable, [global declarations within a handler]

Normally, I wouldn't either.  But I am using a Script Debugger "Library" to simulate an  "#Include header" functionality because I have a huge list of common properties that I want to use in every script of the project. That way I can centralize definitions of these terms so I don't have  to define them in every script or change them in every script when they change.  For example property  standardResponse : "Don't do that" in the header allows every script to use standardResponse and I can change it to "Please don't do that" in the header and it is automatically changed in all other scripts.

This occasions two peculiarities I have noticed.  First, the "header" loads _after_ all the declarations in the script so their definitions can't refer to properties in the "library" header.  Second, properties defined in the "header library" are not visible within the handlers of the main script.  I found I can fix this by declaring them as global within the handler.  Hence, the indentation which your script misses.

A side benefit of having to explicitly declare as global any properties used in a handler is that it forces me to pay attention to them and not make mistakes such as reusing a property's name as a variable within the handler.  For this reason I think I am going to adopt this practice whether I have a header library or not.

Steve
-----------------
OS X 10.6.8, AppleScript 2.1.2


 _______________________________________________
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


  • Follow-Ups:
    • Re: Design Report for Scripts?
      • From: Yvan KOENIG <email@hidden>
References: 
 >Design Report for Scripts? (From: "S. J. Cunningham" <email@hidden>)
 >Re: Design Report for Scripts? (From: Yvan KOENIG <email@hidden>)
 >Re: Design Report for Scripts? (From: Yvan KOENIG <email@hidden>)
 >Re: Design Report for Scripts? (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Design Report for Scripts?
  • Next by Date: Re: Design Report for Scripts?
  • Previous by thread: Re: Design Report for Scripts?
  • Next by thread: Re: Design Report for Scripts?
  • Index(es):
    • Date
    • Thread