Re: Dynamic Handler Call
Re: Dynamic Handler Call
- Subject: Re: Dynamic Handler Call
- From: kai <email@hidden>
- Date: Sun, 9 Apr 2006 23:41:36 +0100
On 8 Apr 2006, at 17:01, Gary Beberman wrote:
I would like to create a list of records in which each record has a
text string and a handler name associated with the string. So, it
would look like:
set hlist to {{searchtext: "text string 1", hname: "handler1()},
{searchtext: "text string 2", hname: "handler2()}, . . . }
A user selects the text from a list, the script finds the
associated hname and calls the handler.
Here's a variation, Gary (including parameters):
-----------
on handler1(p1, p2)
display dialog p1 & ", you " & p2 & " chose handler 1."
end handler1
on handler2(p1, p2)
display dialog p1 & ", you " & p2 & " chose handler 2."
end handler2
set hlist to {{searchtext:"text string 1", hname:handler1},
{searchtext:"text string 2", hname:handler2}}
set tList to {}
repeat with i in hlist
set tList's end to i's searchtext
end repeat
tell (choose from list tList)
if it is false then error number -128
set chosenText to item 1
end tell
repeat with h in hlist
if h's searchtext is chosenText then
set chosenHandler to h's hname
exit repeat
end if
end repeat
chosenHandler((system info)'s long user name, "wisely")
-----------
---
kai
_______________________________________________
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