Re: variables vrs properties
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