Brian Dunning's FileMaker Custom Functions

Occurrences ( text ; casing )

it returns re-occurring strings either upper- or lowercase seperated by a space

  Average rating: 4.0 (3 votes) Log in to vote

John Segers   John Segers - Show more from this author

  Sample input:
Occurrences
("vertegenwoordigers;0")

  Sample output:
e g o r


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

Occurrences (text ; casing) where text is the text to be tested for re-occurring letters. 0 counts re-occuring lowercast and 1 upper.


The function makes use of the ExactPatternCount function that I found here, and which I renamed EPC to return the letters that occur more than once in a given text. And because the orriginal EPC function it's case sensitive.

 

Comments

Omelyan Burtnyk   Omelyan Burtnyk, Go To Logistics
Aug 11, 2018
/*
Thank you
Good job
More readable like:
*/
If(casing=0;
(
If(EPC(text;"a")>1;"a ")&
If(EPC(text ;"b")>1;"b ")&
If(EPC(text;"c")>1;"c ")&
If(EPC(text;"d")>1;"d ")&
If(EPC(text;"e")>1;"e ")&
If(EPC(text;"f")>1;"f ")&
If(EPC(text;"g")>1;"g ")&
If(EPC(text;"h")>1;"h ")&
If(EPC(text;"i")>1;"i ")&
If(EPC(text;"j")>1;"j ")&
If(EPC(text;"k")>1;"k ")&
If(EPC(text;"l")>1;"l ")&
If(EPC(text;"m")>1;"m ")&
If(EPC(text;"n")>1;"n ")&
If(EPC(text;"o")>1;"o ")&
If(EPC(text;"p")>1;"p ")&
If(EPC(text;"q")>1;"q ")&
If(EPC(text;"r")>1;"r ")&
If(EPC(text;"s")>1;"s ")&
If(EPC(text;"t")>1;"t ")&
If(EPC(text;"u")>1;"u ")&
If(EPC(text;"v")>1;"v ")&
If(EPC(text;"w")>1;"w ")&
If(EPC(text;"x")>1;"x ")&
If(EPC(text;"y")>1;"y ")&
If(EPC(text;"z")>1;"z ")
);

If(EPC(text;"A")>1;"A ")&
If(EPC(text;"B")>1;"B ")&
If(EPC(text;"C")>1;"C ")&
If(EPC(text;"D")>1;"D ")&
If(EPC(text;"E")>1;"E ")&
If(EPC(
 
Omelyan Burtnyk   Omelyan Burtnyk, Go To Logistics
Aug 11, 2018
Continue
If(EPC(text;"z")>1;"z ")
);

If(EPC(text;"A")>1;"A ")&
If(EPC(text;"B")>1;"B ")&
If(EPC(text;"C")>1;"C ")&
If(EPC(text;"D")>1;"D ")&
If(EPC(text;"E")>1;"E ")&
If(EPC(text;"F")>1;"F ")&
If(EPC(text;"G")>1;"G ")&
If(EPC(text;"H")>1;"H ")&
If(EPC(text;"I")>1;"I ")&
If(EPC(text;"J")>1;"J ")&
If(EPC(text;"K")>1;"K ")&
If(EPC(text;"L")>1;"L ")&
If(EPC(text;"M")>1;"M ")&
If(EPC(text;"N")>1;"N ")&
If(EPC(text;"O")>1;"O ")&
If(EPC(text;"P")>1;"P ")&
If(EPC(text;"Q")>1;"Q ")&
If(EPC(text;"R")>1;"R ")&
If(EPC(text;"S")>1;"S ")&
If(EPC(text;"T")>1;"T ")&
If(EPC(text;"U")>1;"U ")&
If(EPC(text;"V")>1;"V ")&
If(EPC(text;"W")>1;"W ")&
If(EPC(text;"X")>1;"X ")&
If(EPC(text;"Y")>1;"Y ")&
If(EPC(text;"Z")>1;"Z ")
)
/*
Author: of ExactPatternCount ( text ; searchString ) Richard Dyce
Source: https://www.briandunning.com/cf/2075
*/
 
John Segers   John Segers
Aug 12, 2018
I agree, its much more readable. Thanks for taking time to comment. And thank you for adding the source. I'll addapt the changes and add your name.
 
Richard DeShong   Richard DeShong, Logic Tools
Sep 30, 2026
Hi John, noting that I like the long, single line of code for each of lower and upper alpha letters.
I found it hard to read because of the changes in spaces in the code:
Your first If uses no space: "If(", but in the alpha code, you use "If (", and same with other places.
I prefer no space between function and open-parenthesis: "If(" and "EPC(", but I like spaces around operators: "this > that".
And you have an unneeded parenthesis around the lower alpha build
Finally, instead of using 0/1 for casing, why not lower/upper? It's easier to read/remember.
Here's what it looks like with consistent spacing, removed (), and lower/upper:
If( casing = "lower" ;
If( EPC( text ; "a" ) > 1 ; "a " ) &
;
If( EPC( text ; "A" ) > 1 ; "A " ) &
)
 
John Segers   John Segers
Sep 30, 2026
Sorry Omelyan. When I read your comment It was too hot to do anything but huffing and puffing and after that I totally forgot about it. but thanks to Richard I had it just fixed. Thx for your comment it's appreciated.
 
John Segers   John Segers
Sep 30, 2026
Richard... If I understand you correctly;
The function uses the function EPC. (that means I have to use it's syntax)
So the function reads like "If [text] contains multiple a/A, return 'a ' resp. 'A ' " the space in the return is only there for readability. As for the other (and yes redundant/misplaced) spaces I can only say that prefs are just prefs, we don't have to read it. But you made a very good point (as did Omelyan)
 

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 22 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: