util.FormatWithMask ( text_to_format ; format_mask )
Format text with a simple mask using # as a placeholder for text in the mask
Be the first to rate this function Log in to vote
Pip Meadway - Show more from this author
PIPCO IT |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
This was inspired by the Mask () custom function by Geoffrey Gerhard here: https://www.briandunning.com/cf/872
I have used the FMP18 While () function to implement this rather than making it recursive.
The mask uses a hash character # to show where the text in the text to format is consumed - each # character consumes a single character from the text to format.
If the mask is longer than the text to format, then the return result is only as long as the text to format, conversely if the text to format is longer than the mask, then the return result is only as long as the mask.
e.g.
util.FormatWithMask ( "ABCDE" ; "#######" ) will return "ABCDE"
util.FormatWithMask ( "ABCDE" ; "###" ) will return "ABC"
Anything other than a # character is put into the result as is
e.g.
util.FormatWithMask ( "ABCDE" ; "Start=#-#-#-#-#=The end" ) will return "Start=A-B-C-D-E=The end"
If you need to include a # character as literal text, escape it using the backslash \ character
e.g.
util.FormatWithMask ( 12345 ; "\####-##" ) will return "#123-45"
Comments
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.