Re: finding the index of an item in a list?
Re: finding the index of an item in a list?
- Subject: Re: finding the index of an item in a list?
- From: Stan Cleveland <email@hidden>
- Date: Tue, 31 Jan 2012 20:15:09 -0800
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