• 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: finding the index of an item in a list?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: finding the index of an item in a list?


  • Subject: Re: finding the index of an item in a list?
  • From: Yuma Decaux <email@hidden>
  • Date: Wed, 01 Feb 2012 19:44:13 +1300

Hi Stan,

Thanks for that part. It works fine though the values come with e power symbols. Guess i'll round them up or something.

Oh, and thanks to Zak as well for your suggestion. For some reason applescript told me access denied to 1 of itemlist. Weird, it;s perhaps some coercion issue?

Best regards,

Yuma




On 1/02/2012, at 5:15 PM, Stan Cleveland wrote:

> On Jan 31, 2012, at 7:20 PM, Yuma Decaux wrote:
>
>> Hi List pun intended
>>
>> Been questing at this for a few hours now, almost at the end of my script and i am stuck with finding the index number of an item in a list. I would like to placehold that and use it in an expression such as:
>>
>> Set list1 to get value of every cell of column 4 --that's in the numbers tell block)
>> Set list1 to {}
>> Repeat with i in list1
>> Set nextitem to index of item i +1 --this to increment the item at each pass of the repeat loop
>> Set differential to item i - item nextitem
>> Copy differential to the end of list2
>> End repeat
>>
>> Etc etc
>>
>> The issue i have here is with getting the index of i in the list list1. It just says "can't get index of 0.0054323 --which is the value of that item not its index
>
> Hi Yuma,
>
> It seems that you're trying to find differences between adjacent items, so the following may get you started:
> 	set list1 to {23, 453, 675, 123, 39, 54, 2345, 679, 4563, 8265}
> 	set list2 to {}
> 	set lastitem to 0 -- starting value
> 	repeat with i from 1 to (length of list1)
> 		set nextitem to item i of list1
> 		set differential to lastitem - nextitem
> 		set end of list2 to differential
> 		set lastitem to nextitem
> 	end repeat
> 	return list2
>
> HTH,
> Stan C.
>
>
> _______________________________________________
> 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


 _______________________________________________
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


References: 
 >finding the index of an item in a list? (From: Yuma Decaux <email@hidden>)
 >Re: finding the index of an item in a list? (From: Stan Cleveland <email@hidden>)

  • Prev by Date: Re: finding the index of an item in a list?
  • Previous by thread: Re: finding the index of an item in a list?
  • Index(es):
    • Date
    • Thread