August 9, 201213 yr I am using a simple pattercount function in the middle of a let statement. _stk = patterncount(myfield,"IM") However I need to distinguish between records where myfield contains values like "slim", "blimp" and just "IM") Can the patterncount function use operators like the find statement? I really need to know how many times the the letters "IM" turn up in the field by them selves i.e. not Slim or Blimp etc. Anybody got any ideas to help please? Thanks
August 9, 201213 yr Try perhaps: PatternCount ( " " & MyField & " " ; " IM " ) Note, however, that this will return zero in the following example: "word, IM, another word".
August 9, 201213 yr Seems to me that you should be able to do something like this. Set Variable ($srchterm; Value:"IM") Set Variable [$count; Value:PatternCount(data;$srchterm)] Set Variable ($increment;0) Loop Set Variable ($increment;$increment+1) if [$increment > $count] Exit Script[] end if Set Variable[$position1;Value:Position(data;$srchterm;1;$increment)] /* code here to grab the left couple and right couple characters and check it.. then loop to next occurence. */ end loop
August 9, 201213 yr FMP12? Please update your Profile to reflect your current version of FileMaker Quick Link. TIA Lee
August 14, 201213 yr Newbies Let( breakIntoLines = substitute( myField ; [ "," ; "¶¶" ] ; [ "." ; "¶¶" ] ; [ ";" ; "¶¶" ] ; [ ":" ; "¶¶" ] ; [ " " ; "¶¶" ] ; [ ¶ ; "¶¶" ] ) ; // ... and substitute anything else that also could be a word boundary, by double returns as well PatternCount( ¶ & breakIntoLines & ¶ ; ¶ & "IM" & ¶ ) ) NB: I substitute all punctuation by double returns, in order to give each value its 'own' ¶s before and after. Apparently, PatternCount() reads a string sequentially from beginning to end, which means that if a return already has been detected as the conclusion of an occurrence of "¶IM¶", it will not be counted anymore if the next line would contain "IM" again. PatternCount has no memory of its past. BTW, PatternCount is not case-sensitive, but Substitute is. If you really only want the uppercase occurrences of "IM", you could try this: Let([ breakIntoLines = substitute( myField ; [ "," ; "¶¶" ] ; [ "." ; "¶¶" ] ; [ ";" ; "¶¶" ] ; [ ":" ; "¶¶" ] ; [ " " ; "¶¶" ] ; [ ¶ ; "¶¶" ] ) ; // same as above weirdString = "$#$#$#$#$#$#$#$" ; flagUppercaseIM = substitute( breakIntoLines ; ¶ & "IM" & ¶ ; ¶ & weirdString & ¶ ) ]; PatternCount( ¶ & breakIntoLines & ¶ ; ¶ & weirdString & ¶ ) ) Assuming, of course, that your choice of weirdString is unlikely to occur in your field. HTH Peter
August 14, 201213 yr You might also consider taking advantage of the string being all cap "IM". If this is so, and if you can feel comfortable that your regular text would not contain blIMp or BLIMP then you should be safe: PatternCount ( Substitute ( text ; "IM" ; "~" ) ; "~" ) Actually you can smarten it up a bit with: PatternCount ( Substitute ( text ; [ " IM" ; "~" ] ; [ " IM " ; "~" ] ; [ " IM," ; "~" ] ; [ " IM." ; "~" ] ) ; "~" ) Edited August 14, 201213 yr by LaRetta
August 14, 201213 yr IMHO, the attempt to anticipate all possible punctuation characters is rather naive. If it's important to detect the search string as a word, it would be best to use some xWords functions (in a loop, if necessary) - for example: http://www.briandunning.com/cf/1390 Edited August 14, 201213 yr by comment
October 1, 201213 yr Author Thanks to everyone who offered help. I went in the end with the custom function offered by Brian Dunning. Works great. Thanks
Create an account or sign in to comment