Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 4493 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

Try perhaps:

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

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

Posted

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

  • Newbies
Posted

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

Posted (edited)

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
Posted (edited)

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...
Posted

Thanks to everyone who offered help. I went in the end with the custom function offered by Brian Dunning.

Works great.

Thanks

This topic is 4493 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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