I'd like to know whether a string contains the word from a list. For example, I have 3 strings, 120kV_xxxx, 200kV_abc, abcdefg. I'd like to choose the string started with voltage, and exclude the last one. Now my code is as below. But in python, I can give a list like ["80kV", "120kV", "200kV"], and then use a for loop to judge whether the string contains any word in the list. Is there any similar method in dm-script?
Number find_voltage_prefix(String input)
{
Number sum = -1
sum *= input.find("80kV")
sum *= input.find("120kV")
sum *= input.find("200kV")
if (sum==0) return 1
else return 0
}
Result(find_voltage_prefix("120kV_xxxx"))
Your solution seems fine to me and there is - to my knowledge at least - no internal command that would do the same. You might want to make your routine a bit more flexible by placing the "search for" strings in a TagGroup (TagList) and iterate over it in your search (breaking on first match).
f.e.