LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.
Moderators: LCMark, LCfraser
-
trevordevore
- VIP Livecode Opensource Backer

- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
-
Contact:
Post
by trevordevore » Wed Feb 18, 2015 5:41 am
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
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
livecodeali
- Livecode Staff Member

- Posts: 194
- Joined: Thu Apr 18, 2013 2:48 pm
Post
by livecodeali » Wed Feb 18, 2015 3:57 pm
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
-
trevordevore
- VIP Livecode Opensource Backer

- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
-
Contact:
Post
by trevordevore » Wed Feb 18, 2015 4:11 pm
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.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder