Re: global variables
Re: global variables
- Subject: Re: global variables
- From: Luther Fuller <email@hidden>
- Date: Wed, 17 Jul 2013 16:44:49 -0500
On Jul 17, 2013, at 3:27 PM, Kaydell Leavitt wrote: global x set x to 2 set x to x + 1 display dialog "x: " & x
It always displays 3 as the result.
Yes. You must save a script as an application (bundle) to see the persistence. Save this as an application
-- If you run this from the editor, it always displays "x = 0". -- This script must be compiled as an application (bundle).
on run -- global x my increment() display dialog "x = " & x end run
on increment() global x try set x to (x + 1) on error set x to 0 end try end increment
Every time you launch the application it will display the incremented value of the previous launch. ('global x' is not required in the run handler.)
|
_______________________________________________
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