Newbies rbaron123 Posted December 30, 2009 Newbies Posted December 30, 2009 I have a field that contains a variety of data. I need to know the format for a function that would evaluate the field for the text string that is somewhere in the field (not exclusive) but is within the field. If the string is present within the field, than "x" if not than "y"
efen Posted December 30, 2009 Posted December 30, 2009 If( Position ( textfield ; "your text string to find" ; 1; 1 );"x";"y")
TheTominator Posted December 30, 2009 Posted December 30, 2009 It sounds like you need to look at the Position() function. A nonzero value occurs when the match string has been located.
comment Posted December 30, 2009 Posted December 30, 2009 Either Position() or PatternCount() function can be used for this.
Newbies zazen Posted December 31, 2009 Newbies Posted December 31, 2009 (edited) By "not exclusive" I'll assume that the text string you are searching for may or may not appear in the field. So in A number of records you will have (A - B ) records where the text appears (B being the number of non-occurances). The IF and POSITION functions will certainly give you your X or Y results. Edited December 31, 2009 by Guest
LaRetta Posted December 31, 2009 Posted December 31, 2009 The IF and POSITION functions will certainly give you your X or Y results. Point is - so will PatternCount() as Comment suggested and Case() can be used as well. Case ( PatternCount ( text ; "this" ) ; "x" ; "y" ) All that needs to happen is to produce a boolean true (1 or greater). It doesn't matter how many times the "this" would appear. I believe that JT (-Queue-) once conducted a study over the speed differences between PatternCount() and Position(). He supposed Position() would be faster because it didn't have to count all instances and would stop when first instance was found whereas PatternCount() would need to evaluate the entire field before returning a result. I don't recall his results offhand but I think he was surprised that his supposition didn't necessarily hold true.
Fitch Posted December 31, 2009 Posted December 31, 2009 I believe that JT (-Queue-) once conducted a study over the speed differences between PatternCount() and Position(). He supposed Position() would be faster because it didn't have to count all instances and would stop when first instance was found whereas PatternCount() would need to evaluate the entire field before returning a result. I don't recall his results offhand but I think he was surprised that his supposition didn't necessarily hold true. I'd love to see those results if you're able to dig up the link.
LaRetta Posted December 31, 2009 Posted December 31, 2009 I will look for that thread over the holiday, Tom. Truth is ... spending some of my holiday reviewing JT's threads sounds fun to me. :wink2:
Newbies zazen Posted January 3, 2010 Newbies Posted January 3, 2010 Point is - so will PatternCount() as Comment suggested and Case() can be used as well. Much earlier FMP versions had problems with imbedded multiple IF statements and Case was introduced to address this. Didn't think to replace IF with CASE for a single occurance - thanks for that! As for PatternCount - I can't recall ever having to use it - but then most of the FMP work I have done to date has had little text processing involved. Recently I had to devise a function to extract email addresses from "bounce backs" (dead) so a client could update their records after they sent their regular newsletter out. So, after some experimentation, CASE, MIDDLE and POSITION did the job on the bulk (about 99%) of the bounce backs. I can see that text processing is going to become more and more of a requirement - interesting times ahead :
Recommended Posts
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