Re: Variables inside handlers
Re: Variables inside handlers
- Subject: Re: Variables inside handlers
- From: Ben Waldie (AppleScript Guru) <email@hidden>
- Date: Wed, 11 Dec 2002 00:09:29 -0500
Rob,
On Tuesday, December 10, 2002, at 11:48 PM, The Other Rob wrote:
>
My problem is that the scope of the variables (test1, test2, test3) is
>
limited to that particular handler, and I can't access them from other
>
parts
>
of my test3app script. Is there any way to make these variables
>
available
>
to the rest of my script?
There are a few things you can do.
1) You could return the variable values to the code/script that's
calling your subroutine.
on someHandler()
set x to 1
set y to 2
set z to x + y
return {x, y, z}
end someHandler
Then, from the loaded script, simply say something like...
tell theLoadedScript to set myVariables to someHandler()
2) You could declare your variables as globals.
on someHandler()
global x, y, z
set x to 1
set y to 2
set z to x + y
end someHandler
Then, from the loaded script, simply say something like...
global x, y, z
tell theLoadedScript to someHandler()
x
y
z
3) You could use properties to store your variables.
property x : 0
property y : 0
property z : 0
on someHandler()
set x to 1
set y to 2
set z to x + y
end someHandler
Then, from the loaded script, simply say something like...
tell theLoadedScript to someHandler()
x of theLoadedScript
y of theLoadedScript
z of theLoadedScript
Hope this helps. Thanks,
- Ben
Benjamin S. Waldie
AppleScript Guru
http://www.applescriptguru.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.