• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dynamic Handler Call
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Dynamic Handler Call
      • From: Emmanuel <email@hidden>
References: 
 >Re: Store script as run only (From: has <email@hidden>)
 >Re: Store script as run only (From: Jens Eliasson <email@hidden>)
 >Dynamic Handler Call (From: Gary Beberman <email@hidden>)

  • Prev by Date: Re: Dynamic Handler Call
  • Next by Date: Re: Weird behavior - Script saved as application...
  • Previous by thread: Re: Dynamic Handler Call
  • Next by thread: Re: Dynamic Handler Call
  • Index(es):
    • Date
    • Thread