Searching Array For String ? Help ?


mawright89

Recommended Posts

I have a number of individual scripts which have result arrays ascociated with them. They have string "Pass" or "Fail" values. I want to search through the arrays quickly and return lets say a 0, or 1 depndant on weather any of the strings are of value "Fail".

Is there a quick way to search through arrays for a value without hanging if one of the array parts is empty?

Cheers

Link to comment
Share on other sites

I'm not sure what you mean by "empty", but you can just use search() for this:

private index = search(myArray == "Fail")

will return the index of the first item that == Fail, or -1 if not found. There is an optional parameter for start, so you can do:

private index = -1

while(1)

index = search(myArray == "Fail", index+1)

if (index == -1)

break

endif

? index

endwhile

Which will print the indices of all the elements == "Fail"

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.