Re: executing blocks of code
Re: executing blocks of code
- Subject: Re: executing blocks of code
- From: Graham Anderson <email@hidden>
- Date: Tue, 25 Jan 2005 11:55:01 -0800
seems that all the handlers are executing at the same time :(
it it possible for handlers to run sequentially? One finishes...then
the next one begins ?
I need the equivalent of pasting a big block of code into the final
compile when you say
myHandler()
is this possible...kind of like an 'include' statement?
On Jan 24, 2005, at 6:57 PM, Andrew Oliver wrote:
On 1/24/05 6:35 PM, "Graham Anderson" <email@hidden> wrote:
I have various functions I have created to try to simplify my code....
no variables are being passed..they are just executing big blocks of
code
normally, in my other installer [on the PC] I would use:
Function myFunction
....code
Function End
when i want to call that function, I just : call myFunction
is there an equivalent in applescript ?
Sure. The equivalent in AppleScript are 'handlers':
on myHander1()
-- code goes here
end myHandler1
on myHandler2()
-- more code goes here
end myHandler2
on run
-- main code that calls other handlers:
myHandler1()
myHandler2()
end run
Note that you can pass parameters to the handlers by declaring them
within
the parentheses and passing in the same number of parameters when you
call
the handler. Also watch out for scope - variables declared in one
handler
are not accessible to other handlers unless they are declared as
global.
Finally, for now, handlers can return results back to the caller like:
on getRandom()
set someVar to random number from 1 to 10
return someVar
end getRandom
on run
set randNum to getRandom()
display dialog "Your lucky number is " & randNum
end run
Andrew
:)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden