Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

String corollary to ug_findNumberInList() 1

Status
Not open for further replies.

rooseter

Bioengineer
Sep 27, 2012
2
The ug_findNumberInList() works great for lists of numbers but I am struggling to find a similar way to search a list of string values for the position of a particular value in the list.

If I have a list expression as follows.

{"A","C","B"}

And I want to know the position of "B" in that list, how can I accomplish this task? I would want it to return a value of 2 after starting with zero for the first position.

[NX8.5.3.3]
 
Replies continue below

Recommended for you

OK, there's actually on 'undocumented' function which works much better for everyone concerned (I'm working on getting it properly documented). And that is the 'Position()' function. Now it works similar to the 'ug_findNumberInList()' function except that it supports BOTH numeric and alphabetical (i.e. Stings) 'List' entries.

So for your situation, it would go something like:

My_List = {"A","C","B"}
Number = Position("B",My_List) = 3


Please note that this will return a '3' and not a '2' as would the 'ug_findNumberInList()', if it would have worked with Strings.


John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
[thumbsup] Thank you very much sir! Exactly the simple solution I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor