Brian Dunning's FileMaker Custom Functions

PatternCountMultiCS ( Text ; SearchList )

A case sensitive version of my function PatternCountMulti

  Average rating: 5.0 (1 vote) Log in to vote

flusheDData   flusheDData - Show more from this author
n/a
http://www.udias.com

Share on Facebook Share on Twitter

  Sample input:
PatternCountMultiCS ( "The more I type, the more I mistype" ; "theĀ¶more")
  Sample output:
3

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

A case sensitive version of the funcion PatternCountMulti.
It uses the Substitute trick much used in Excel.

 

Comments

Richard Dyce   Richard Dyce, Dyce & Sons Ltd.
Jun 2, 2020
Just a thought, but might it not be cleaner to use a While() instead of the recursion and the variables? e.g.

While (
[
~counter = 1 ;
~found = 0
] ;

~counter <= ValueCount ( SearchList ) ;

[
~searchTerm = GetValue ( SearchList ; ~counter ) ;
~found = ~found + (
Length ( Text ) - Length ( Substitute ( Text ; ~searchTerm ; "" ) )
) / Length ( ~searchTerm ) ;
~counter = ~counter + 1
] ;

~found
)

I keep meaning to go back through all my recursive CFs and change them to While()s .
 
flusheDData   flusheDData, n/a
Jun 2, 2020
Hi Richard and thank you so much for your feedback.
Yes, I consider the while function very interesting, in fact I am using it on a daily basis.
Anyway, I do not mean to change my funcions to the while version as they are very portable and compatible with previous FMP versions. I usually tend to make most of my solutions as much backwards compatible as posible.
Best regards,
Miguel
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: