• 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: variables vrs properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variables vrs properties


  • Subject: Re: variables vrs properties
  • From: Luther Fuller <email@hidden>
  • Date: Thu, 06 Jan 2011 08:46:17 -0600

On Jan 6, 2011, at 8:27 AM, Jim Brandt wrote:

When I've used globals, I've always defined them at the top of the script.

I can then use them in a handler later.

But, be aware that ...

Any variable used in the run handler (implicit or explicit) is automatically global. You don't have to explicitly declare it a global. If you want a run handler variable to be local, then you DO have to explicitly declare it local in the run handler. Variables in other handlers are automatically local.

I recently posted this ...

on run
try
my main()
on error errText number errNr
if errNr = -128 then
return
else if errNr = -2700 then
tell application "Mail" to display dialog errText buttons {"OK"} default button 1
else
"Error = " & errNr & return & errText
display dialog the result buttons {"OK"} default button 1
end if
end try
end run -------------------------------------------------------

on main()

end main -------------------------------------------------------

which is my way of avoiding any variables in the run handler
and also provides a 'standard' method of handling errors.

 _______________________________________________
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: variables vrs properties
      • From: Alex Zavatone <email@hidden>
    • Re: variables vrs properties
      • From: KOENIG Yvan <email@hidden>
References: 
 >Re: variables vrs properties (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: variables vrs properties
  • Next by Date: Re: variables vrs properties
  • Previous by thread: Re: variables vrs properties
  • Next by thread: Re: variables vrs properties
  • Index(es):
    • Date
    • Thread