Re: Run Handler-Name from Text?
Re: Run Handler-Name from Text?
- Subject: Re: Run Handler-Name from Text?
- From: Tetsuro Kurita <email@hidden>
- Date: Thu, 19 Apr 2012 09:55:14 +0900
>
>>> on myHandlerName()
>>> display dialog "Yes!"
>>> end myHandlerName
>>>
>>> run script "on run {fred}
>>> tell fred to myHandlerName()
>>> end" with parameters {me}
>
>> Following code will be better.
>>
>> on myHandlerName()
>> display dialog "Yes!"
>> end myHandlerName
>>
>> set broker to run script "script
>> on do(target)
>> target's myHandlerName()
>> end do
>> end script
>> return result"
>>
>> broker's do(me)
>>
>> Above code can avoid to copy the script object indicated by "me".
>
> Yes. That's certainly faster. Thanks!
>
> I presume that by "copy" you're saying that my version compiles a copy
> of the main script into the one created by "run script"?
>
Yes. "run script" command will generate another script instance. Therefor
values passed by "with parameters" will be copied always.
Above technics is generalized and packed into a module.
http://www.script-factory.net/XModules/XHandler/en/index.html
property XHandler : module
boot (module loader) for me
on myHandlerName()
display dialog "Yes!"
end myHandlerName
XHandler's make_with("myHandlerName", 0)'s do(me)
=======================================================
Tetsuro KURITA
E-mail: email@hidden
http://www.script-factory.net
=======================================================
_______________________________________________
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