Re: multi-dimensional arrays (new to AS)
Re: multi-dimensional arrays (new to AS)
- Subject: Re: multi-dimensional arrays (new to AS)
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 26 May 2004 09:54:07 -0700
On 5/26/04 9:01 AM, "Sprague, Graham" <email@hidden> wrote:
>
Hey Jeff,
>
>
You seem pretty knowledgable when it comes to lists and records. I have a
>
question for you.
>
>
Is it possible to access a Key:value pair from a record when the key is
>
stored in a variable.
>
>
for example this causes an error but may illustrate what I'm attempting to
>
do...
>
>
> set theRecord to {mike: 1, jill: 10, sue: 3, paul: 20}
mike is a variable name here: a record _label_ in AS terms.
>
>
>
set keyToSearchFor to "mike"
Completely different. "mike" is a string here.
>
>
set valueForKey to keyToSearchFor of theRecord-- Does not work gives error
>
"cant get keyToSearchFor of {mike: 1, jill: 10, sue: 3, paul: 20}"
That's evaluates to:
set valueForKey to "mike" of theRecord
theRecord contains no "mike" (string). You can only ask for a label of the
record, getting back its value. You can't ask for a string "mike".
On the other hand, you can ask for
set valueForKey to mike of theRecord
--> 1
>
>
>
Seems like it's not accepting the variable contents, in this case "mike"
That's not the variable contents. The variable name is mike and its contents
(value) is 1.
>
and is attempting to use the variable name, in this case "keyToSearchFor" as
>
the key.
That's how it works.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.