Re: Handlers first?
Re: Handlers first?
- Subject: Re: Handlers first?
- From: Stan Cleveland <email@hidden>
- Date: Mon, 24 Oct 2011 11:23:04 -0700
On Oct 22, 2011, at 1:36 AM, Shane Stanley wrote:
> There is at least one case in AS where script objects need to be declared before they are called -- or, at least, there was.
A script object inside a handler must be defined before it is called. If not in a handler, a script object can be can be called from anywhere, before or after its definition.
This fails:
sayHello()
on sayHello()
run script s -- or just 'run s'
script s
display dialog "Hello."
end script
end sayHello
This works:
sayHello()
on sayHello()
script s
display dialog "Hello."
end script
run script s -- or just 'run s'
end sayHello
The command "run script" from Standard Additions is technically the correct one to use. It surprises me that the "run" command even works! AS seems to be fudging its own "run" command, which is intended to run applications, not script objects. (I'm still on SL, BTW, so don't know how any of this works on Lion.)
Stan C.
_______________________________________________
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