string from a string list

Hi,
I want to check if a particular string is existing in a given string list.
example : lets say the string list has 1, 2, 3, 4, 5 and if i pass 3 as a string input, it should return me (yes or no) or (true or false).
do we have something this kind of inbuilt service in our wm developer.
Please let me know.

FYI. I am using wm developer7.1.2.

Thanks,
Bala.

The only service I can think of is a pub.string:lookupTable in the WmPublic pacakge which takes in a String [][] and a key and returns the value.

If you want to return true/false, I’d suggest using a Java service to do the work.

Something like


String key = "3";
String[] words = {"1","2","3","4","5"};
List<String> wordList = Arrays.asList(words); 
if(wordList.contains(key)) {
    return true;
}
return false;

Thanks.

I searched for inbuilt services, but didnt find much… so we wrote one java service which served the purpose.

Java is one way. The same can be done in FLOW as well. And can be debugged using Developer. Here are the steps for a service that accepts a string list name myList and a string to look for name myValue and returns a var name found:

MAP (set found = false)
LOOP over ‘/myList’
…BRANCH (evaluate labels = true)
…%/mylist% == %/myValue%: SEQUENCE
…MAP (set found = true)
…EXIT ‘$loop’ and signal SUCCESS

yes, i did this before. but we want to avoid using loop because we have a string list of various folder names ranging from 2000 to ~. this way loop takes much time

If performance is really a concern, then maybe you should consider different approaches to help speed up the look up, such as using hash tables or sorted lists.

  • Percio