Brian Dunning's FileMaker Custom Functions

InsertCharacter ( text ; index ; char )

Inserts a specified character in between each character of a specified string.

  Average rating: 4.3 (32 votes) Log in to vote

George Norsworthy   George Norsworthy - Show more from this author
Bell Mountain Assoc.
http://bellmountainassoc.com

Share on Facebook Share on Twitter

  Sample input:
InsertCharacter ( "Filemaker" ; 9 ; "_" )
  Sample output:
F_i_l_e_m_a_k_e_r

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

Inserts a specified character in between each character of a specified string. The variable "index" needs to be the length of the "text" string.

 

Comments

Gary   Gary, GC Consulting
Sep 13, 2013
Am I missing something here? When I use this function (which is very cool, btw), it also inserts a trailing char…

The above mentioned sample output is on my machine: F_i_l_e_m_a_k_e_r_

It doesn't matter in my database, but it would be nicer if the trailing char would not be there.

Anyone any ideas?
 
unix   unix, Japan
Sep 28, 2013
Case ( Index < 2 ; Text ;
InsertCharacter ( Replace ( Text ; Index ; 0 ; chr ) ; Index - 1 ; chr )
)
 
Jorge Lopez   Jorge Lopez
Mar 4, 2020
How can I use this function in FM 16?
It does not work with chr variable, but changing variable name it does work:

Case ( Index > 1 ;

InsertCharacter ( Text; Index - 1; cad ) & Middle ( Text; index; 1 ) & cad; Left ( Text; 1 ) & cad )

But when using
InsertCharacter ( "FILEMAKER" ; 9 ; "_" )
the result is
8__9_

Some help about this issue?
Thanks in advance and best regards
 

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: