• 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: multi-dimensional arrays (new to AS)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Prev by Date: Re: A funny think happened...
  • Next by Date: Re: A funny think happened...
  • Previous by thread: RE: multi-dimensional arrays (new to AS)
  • Next by thread: RE: multi-dimensional arrays (new to AS)
  • Index(es):
    • Date
    • Thread