Re: Records in handlers
Re: Records in handlers
- Subject: Re: Records in handlers
- From: Adam Bell <email@hidden>
- Date: Mon, 6 Feb 2006 10:25:48 -0400
In simpler form, this shows the failure - AppleScript won't coerce the text to a reference:
set MyRecord to {A1:"Foo", A2:"Bar"}
choose from list {1, 2}
set myPick to "A" & result
return MyRecord's myPick
--> Errors with: Can't get myPick of {A1:"Foo", A2:"Bar"}.
There's a hack that will get around this but who knows for how long:
on quoted_text for v
try
{v}'s v
on error v
set d to text item delimiters
set text item delimiters to "{"
set v to v's text from text item 2 to end
set text item delimiters to "}"
set v to v's text beginning thru text item -2
set text item delimiters to d
v
end try
end quoted_text
set MyRecord to {A1:"Foo", A2:"Bar"}
choose from list {1, 2}
set myPick to "A" & result
set myVal to run script (quoted_text for MyRecord) & "'s " & myPick
will correctly return your choice. Bear in mind that it relies on behavior that is totally unguaranteed to continue long term.
Adam
On 2/6/06, Jay Louvion <email@hidden> wrote:
I'm getting to have "fun" with some handlers and records; Unfortunately stumbling on some tough piece I can't figure out for myself.
This works fine:
set TheRecord to {Mine:{theAddress:"
email@hidden", thelink:"http://www.ical.mac.com/jay/jay"},
His:{theAddress:"email@hidden",
thelink:"http://www.ical.mac.com/jay/him"}}
return theAddress of His of TheRecord
But if the "His" is passed on as a param in a handler, or just from a text returned of dialog, it errors out. Am I supposed to coerce the text into a record or something ? I've tried, but it doesn't seem to yield any results.
set TheTypedName to (text returned of (
display dialog "What's the name?" default answer "")) as string
GetDetails(TheTypedName)
on GetDetails(who)
set TheRecord to {Mine:{theAddress:"
email@hidden", thelink:"http://www.ical.mac.com/jay/jay"},
His:{theAddress:"email@hidden",
thelink:"http://www.ical.mac.com/jay/him"}}
return theAddress of who of TheRecord
end GetDetails
With a "Can't get who of {Mine:{theAddress:"email@hidden", thelink:"
http://www.ical.mac.com/jay/jay"}, His:{theAddress:"email@hidden", thelink:"
http://www.ical.mac.com/jay/him"}}." error. Rather fun to read, but kinda disappointing to a young scripter like myself.
TIA anyone...
J.
Jay Louvion
Studio Casagrande
3, rue Müller-Brun
1208 Geneva
T+4122 840 3272
F+4122 840 3271
skypeme:
jaylouvion
www.studiocasagrande.com
P
Please consider the environment before printing this email.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (
--
Some minds remain open long enough for a truth to both enter and leave without processing.
_______________________________________________
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