Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

Try perhaps:

PatternCount ( " " & MyField & " " ; " IM " )

Note, however, that this will return zero in the following example: "word, IM, another word".

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

FMP12?

Please update your Profile to reflect your current version of FileMaker Quick Link.

TIA

Lee

  • 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

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 by LaRetta

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 by comment

  • 1 month later...
  • 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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.