Brian Dunning's FileMaker Custom Functions

InsertChar ( inText ; insertChar ; atInterval ; outText )

Insert character at regular intervals within text

  Average rating: 3.9 (45 votes) Log in to vote

Michael Rauch   Michael Rauch
ShopWorks
http://www.shopworx.com

Share on Facebook Share on Twitter

  Sample input:
InsertChar ( TO::GeneSeq ; " " ; 4 ; "")
where the field TO::GeneSeq contains "ATTTCTTTTTTTCCTCTTTC"
  Sample output:
ATTT CTTT TTTT CCTC TTTC

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

Tail recursive custom function that inserts the specified character at the specified interval.

 

Comments

Brian   Brian, Mexico
Mar 14, 2015
Yout formula ruins my file!!!!! got into a loop can't get rid of it
 
mbraendle   mbraendle, Zurich
Aug 6, 2015
- Uses a parameter name that is the same as the function name. FileMaker 13 complains about this.
- atInterval is not checked for zero or negative values
- otherwise function runs fine
 
Arjen van der Ree   Arjen van der Ree, Amsterdam
Oct 26, 2015
Worked fine for me I altered the function first:
1. renamed to 'InsertCharacter'
2. slight code change:

Let(
[
addText = Left ( inText ; atInterval);
nextText = Right ( inText ; Length ( inText ) - atInterval );
outText = outText & Case ( Length ( outText ) > 0 ; insertChar ) & addText
]
;
Case ( Length ( nextText ) > 0 ; InsertCharacter ( nextText ; insertChar ; atInterval ; outText ) ; outText)
)

Don't care much for the outText-feature but I'm not complaining !
Thnx again, real time saver !

Cheers, Arjen van der Ree
 

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: