Page 1 of 1

Finding element in list and getting offset

Posted: Wed Feb 18, 2015 5:41 am
by trevordevore
I'm searching a list for a matching element. I see that there is syntax for determining if an element is found in a list, but no syntax that returns the element number of the element in the list. Does the syntax exist and I just don't see it documented? Or is this an oversight? Or is it not really needed?

Here is my workaround:

Code: Select all

variable tElement as string
  repeat with tElement from 1 up to the number of elements in mTags
		if pTag is element tElement of mTags then
			put tElement into mSelected
			exit repeat
		end if
	end repeat

Re: Finding element in list and getting offset

Posted: Wed Feb 18, 2015 3:57 pm
by livecodeali
Hi Trevor,

Yes you are correct that it doesn't currently exist - we probably should add it for consistency with the other chunk offset functions. Your workaround is probably only marginally less efficient than using such a function though.

Ali

Re: Finding element in list and getting offset

Posted: Wed Feb 18, 2015 4:11 pm
by trevordevore
I agree that it should be added for consistency. I don't know about others, but this is a common operation for me when using lists.

Re: Finding element in list and getting offset

Posted: Wed Feb 18, 2015 7:30 pm
by livecodeali