AddConstantToString ( string ; fillchar ; posit ; direction ; iter )
Adds a constant string to very Nth position of a string
Average rating: 4.5 (33 votes) Log in to vote
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Recursive CF that formulates output strings by adding a constant string to every Nth position resulting a more readable grouped output for longer strings ( f.eg Bank references, serial numbers etc).
Grouping starts either Right (default) : 12-345-678 or Left: 123-456-78
Sep 8, 2009
You have an error in the CF. You have changed the name of your CF where it calls itself.
Solution is to change the name of the CF,
Or better yet, change the Calculation where it calls itself. i.e.
change AddFillCharToString to AddConstantToString
Martti Tumanto, Espoo, Finland
Sep 9, 2009
|Corrected, thank you Lee|
Mike, Tennessee USA
Oct 22, 2015
I'm new to custom functions so I'm trying to learn the logic behind specific lines in this.
1. The "char" variable is set to the Mod function, but what does the <> 0 do? I cannot find where that would be supported as it's outside the Mod function.
2. The "stringout" function uses the Case function. The first test checks for iter=1, and sets the result to blank if true. There are no other tests within this Case startement however, but there are 3 more segments after this. I assume these to be default values, but that would mean three default values. How can you have more than one default in a single Case statement?
stringout = Case
iter = 1 ; "" ; //test and result if true
char ; //no test so default 1
dir1 ; //no test so default 2
fillCharacter //no test so default 3
The function works, I just don't know how it does with these variables defined that way.
Martti, Espoo, Finland
Oct 22, 2015
Thank you for your comment. Nice to hear that CF works. Here is some explanation about the magic:
1. char = Mod (iter ; posit+1) ≠ 0 . This is a Logical statement, equivalent to
char = if ( Mod(item ; posit+1 = 0 ; 1 ; 0)
2. Stringout-function ; please check the syntax of Case function: in this case
case (item = 1 ; "" ; // OK? write nothing in 1st iteration, just initiate recursive variables
char ; dir1 //if char flag is on , write the char (the names of these variables are admittedly misleading)
fillChacracter // this is the default ; write the fillchar
Happy learning with Filemaker!
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.