Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

Format_Text_LikeTemplate__CFpub ( aString ; aTemplate )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 2.5  (233 votes)
  Discuss this Custom Function

Toby Beedell, na
http://na

Use to Format Numbers or Text for displaying in a structured way, for instance Phone Numbers or Bank Codes

Sample Input:
Format_Text_LikeTemplate__CFpub ( "1234567890" , "(XXX) XXX-XXXX" )
Sample Output:
"(123) 456-7890"


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

This function will strip out any non-alphanumeric (A-Z, a-z & 0-9) characters and format the result in the same structure as provided by the aTemplate parameter.
I have opted to use the upper and lower case of the letter 'X' as my content key in the mask template,
but you can use whatever character you want by changing the '_x' variable in the first Let statement.

You can include any characters you wish in the mask (keeping in mind that 'X' and 'x" will be replaced) and the function will include them in
exactly the same position in the result.

The function will start from the beginning of the mask template looking for the first occurence of 'X' or 'x',
If your mask template does not start with an X (for instance you may want to indent or prepend some text or numbers to the beginning)
then the function will place this individual or sequence of non-X characters at the start of the result.
NOTE: If you do not supply any X characters in the mask template then the entire set of mask characters will show up in front of the original text.
This is not a bug as this sort of result may in fact be exactly what is desired.

Once it has found the position of the first X in the mask, it grabs the first character of the filtered text and replaces the X with the text character.
It then passes the remainder of the mask and the remainder of the filtered text on for another pass of the function.
This process is repeated over and over until either the text is empty or the mask has finished.

In the case of the later ... the function will simply add the remaining text characters to the end of the result.

Paramaters:
aString: the text to pass
aTemplate: a string of text to represent the formatting. (Accepted parameter: a string of X or x to signify content and any other characters to insert as delimiters)

Sample Input:
// maybe you want to format phone numbers like so ...
Format_Text_LikeTemplate__CFpub ( "1234567890" , "(XXX) XXX-XXXX" )

// or have a need to mix up upper and lower cases within a structured code
Format_Text_LikeTemplate__CFpub ( "gbabcdefcom" , "xx*XXX.XxX.xxx" )

// maybe you have a "dewey decimal"-like system that needs to be formatted a particular way
Format_Text_LikeTemplate__CFpub ( " 6171234567890 " , "xxx.xxxx.xxx.xxx" )

// or for instance to format IBAN banking codes
Format_Text_LikeTemplate__CFpub ( "gb-90-midl12341234123412" , "XXXX XXXX XXXX XXXX XXXX XX" )

Results:
"(123) 456-7890"
"gb*ABC.DeF.com"
"617.1234.567.890"
"GB90 MIDL 1234 1234 1234 12"

Recursive:
yes

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

Discuss:

There are no comments yet. Be the first to post a comment about this Custom Function! Please try to keep it brief & to the point. Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 0 + 5 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)
2. MonthYearList ( startmonth ; startyear ; numbermonth ; short )
  (Mon, Oct 16, 3:38am)
3. ErrorDescription ( errorNumber )
  (Wed, Sep 27, 2:51am)
4. decodeEntities (text)
  (Wed, Sep 27, 1:22am)
5. HexidecimalToNumber ( HexidecimalValue ; counter )
  (Mon, Sep 25, 12:39pm)
6. FixedFieldConverter ( Fieldname ; f1 ; f2 ; f3 ; f4 ; f5 ; f6 ; f7 ; f8 ; f9 ; f10 ; f11 ; f12 ; f13 ; f14 ; f15 ; f16 ; f17 ; f18 ; f1
  (Fri, Sep 15, 12:34pm)
7. ShannonEntropy ( text )
  (Thu, Sep 07, 5:59am)
8. LetterCount ( text ; summary )
  (Thu, Sep 07, 5:53am)

RSS Feed of Custom Functions