Search with arrays containing strings


asmith

Recommended Posts

  • 2 weeks later...

Maybe we are running different versions of DAQFactory, I still cant get it to work. I have 5.84 Build 1636

Here's what happens when I try the same thing....

global y = {"a", "b", "c"}

?y

{NaN, NaN, NaN}

? search(y == "b")

C1097 String operator found when number expected.

If I declare the global as a string array (which is what I'm trying to search) such as.....

global string df

df[0] = 'DAQFactory"

df[1] = 'is"

df[2] = 'very"

df[3] = 'good"

?df

{"DAQFactory"", "is"", "very"", "good""}

?search(df=="is")

-1

Any ideas?

Thanks

Link to comment
Share on other sites

Sorry, typo on my part. I entered global string x = ..., not global x. Global x would create an array of numbers.

You also have a typo, which is why it isn't working. When you are defining the various array elements, you open your string with a single quote and then close it with a double quote. The reason DF supports both single and double quotes is to allow you to put one type in a string without escaping: 'he said: "hi"'. DF isn't checking for the closing ' and assumes the end of the line is the close, so, as you can see when you do ? df, there is a " in your string. So, search(df=="is") returns -1, because there is no "is" in the array, but there is "is"" (three characters, the last being ")

Link to comment
Share on other sites

Archived

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