Checking if a number is exist in a list of numbers

Hi everyone
I want to do a check if a variable that I got from a table (a string or int) exists inside of a list of numbers.
an example:
I created a string of numbers like this: {“1", “10”, “19”, “35”, “36”, “37”, “38”, “45”, “46”, “47”, “61”, “63”, “64”, “65”, “66”, “68”, “90”, “92”, "93”} and I want to check if a variable (string or int) is exist in that list?


I want to do the checks inside the "flow decision"s.
thanks a lot everyone

@dlichtenstadt
yourStringArrayVar.Contains(yourSearchedString) will return true or false

1 Like

ok
and if i will search for the string “1” and i dont have “1” in the list, but i have “10” wont it find the “10”?

@dlichtenstadt
grafik
as you can refer 10,12,11 is not changing the output to true, it is false as 1 is not as an item present in the array

working with the watch panel / immediate panel allows you to explore such things very quickly

the contains method is not the same contains method of a string. It is related to collections and looks for items within the collection

1 Like

thank u
I just ran it and it worked,
i just wasnt sure…

I ran it in my actual program and for some reason it’s not working

image

the variables is string {“1”,“2”,“3”,“4”,“5”}, and another string with “2”
image
the in_busvehicletype is the list, and in_ROW(2).tostring is the variable

debug it and follow the flow

I did it crashed on this
image
if i’m doing invoke with this “string” it’s not working?

if I want to change this array to a string with a comma between the values
how do I run on it and do the searches?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.