• 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: Addressing List Items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Addressing List Items


  • Subject: Re: Addressing List Items
  • From: Michelle Steiner <email@hidden>
  • Date: Wed, 04 May 2011 08:25:08 -0700

On May 4, 2011, at 8:09 AM, Marconi wrote:

> I've never used lists before. I've googled and cannot find an answer to my very basic question.
>
> How does one populate an empty list? What is the proper way to address list items?

You copy it to the end of the list:

set my_list to {}
copy "1" to end of my_list
copy "apple" to end of my_list
my_list
--> {"1", "apple"}

> set EditArray to {}
> set aValue to 0 -- for this example
>
> repeat with LineNumber from 1 to 5
> 	--here I would calculate the value of EditStart
> 	set EditStart to aValue
>
> 	-- here I would calculate the value of EditEnd
> 	set EditEnd to aValue
> 	set item LineNumber of EditArray to {EditStart, EditEnd}
>
> 	set LineNumber to LineNumber + 1
> end repeat
>
> 	Can't set Item 1 of {} to {0, 0}.
>
>
> Apparently, "Item x of EditArray" is not the proper way to refer to the first record of EditArray. Neither is "record x of EditArray"
>
> What's the proper way to address records of a list?

Records and lists are two different things.

You address list items by their indexes, and records by their labels:

set list_of_stuff to {1, "apple", 3, "pear", true, 4, "banana", 5}
item 5 of list_of_stuff
--> true

set record_of_stuff to {alpha:1, bravo:"apple", charlie:3, delta:"pear", echo:true, foxtrot:"banana", golf:5}
delta of record_of_stuff
--> "pear"

-- Michelle

--
Do not go out and kill Klansmen, no matter how much they deserve it. It would be funny as hell to see on the evening news how a bunch of guys wearing bright pink robes and hoods started burning triangles in their yards for a change.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Addressing List Items
      • From: Walter Bushell <email@hidden>
References: 
 >Addressing List Items (From: Marconi <email@hidden>)

  • Prev by Date: Addressing List Items
  • Next by Date: Re: Addressing List Items
  • Previous by thread: Addressing List Items
  • Next by thread: Re: Addressing List Items
  • Index(es):
    • Date
    • Thread