I7 : Position of an item in a list

Struggling with the syntax of this. Sorry. I just need to return the position of an item in a list. Specifically, a list in a table.

So, for example

Table of thingsinlists
OThing(a list of text)
{"apple", "banana","cherry","pear"}

So in this case, I can say

Choose row 1 of Table of thingsinlists;
Let L be entry 3 of OThing entry;

But what I want is for L to be the ‘position’ of “cherry” in the list - in this case 3.

Apologies if this has been answered before - I’ve had a search and can’t see anything. I’ve also searched through docs and can’t see anything.

Before I start writing a routine to count through the list until it matches “cherry”, is there something like :
Let L be entry position of "cherry" in Othing entry.

I don’t think there’s a built-in “index of” function for lists in I7. You’d have to do something like this:

To decide which number is the position of (E - K) in (L - list of values of kind K):
	repeat with idx running from 1 to the number of entries in L:
		if entry idx in L is E, decide on idx;
	decide on -1.

Then you could ask for the position of "cherry" in the list of fruits (or in the OThing entry, or wherever).


Yeah, I thought as much, but it was definitely worth checking! :slight_smile:
Thank you!