James Gill Posted May 19, 2015 Posted May 19, 2015 (edited) I am trying to search for a simple text string within a List of text strings and return a boolean result if the search text string exists within the list. From what I understand, I can use FilterValues to accomplish this. FilterValues ( "mySearchString" ; $MY_LIST_OF_VALUES ) If 'mySearchString' exists within the variable list 'MY_LIST_OF_VALUES', it will return 'mySearchString'. I should then be able to use the GetAsBoolean function to return TRUE if the value is there and FALSE if the value is not found, correct? If not, what's the correct method to do this? Edit: Well from the Function reference for GetAsBoolean, I guess not. Although even when I say: If ( FilterValues ( "mySearchString" ; $MY_LIST_OF_VALUES ) = "mySearchString" ; True ) It returns false... Edit 2: Well I'm stupid. Turns out the function I was using to Add and Remove values from a list was adding a trailing ¶ to the first value once multiple values had been added to the list. The above function returned True during the first creation of the global value list and then failed each subsequent time. Now I know why... Code ( "mySearchString" ) ≠ Code ( FilterValues ( "mySearchString" ; $MY_LIST_OF_VALUES) ) but Code ( "mySearchString¶" ) = Code ( FilterValues ( "mySearchString" ; $MY_LIST_OF_VALUES ) ) :facepalm: Edited May 19, 2015 by James Gill
comment Posted May 19, 2015 Posted May 19, 2015 I should then be able to use the GetAsBoolean function to return TRUE if the value is there and FALSE if the value is not found, correct? No, that is incorrect. GetAsBoolean ( string ) does not test for the existence of string (unlike many other languages). The correct test is = not IsEmpty ( FilterValues ( "mySearchString" ; $MY_LIST_OF_VALUES ) )
Josh Ormond Posted May 20, 2015 Posted May 20, 2015 (edited) Is there is benefit to using this approach as opposed to PatternCount ( )? Edit: Nevermind. I just realized you are trying to match the entire value, not just part of the string/value. Edited May 20, 2015 by Josh Ormond
Recommended Posts
This topic is 3532 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now