Function overview
Prototype
format.UkTelNumber (
telNo )
Parameters
telNo
Description
Tags:
telephone phone Format
Formats a string on numbers/letters to UK telephone number format
Examples
Sample input
format.UkTelNumber("01234567890x123")
Sample output
01234 567890 x123
Function code
/*
Name:
format.UkTelNumber
History:
Created by Tim Anderson, Tim Anderson Group
www.timanderson.co.uk
Creation Date: 3 April 2009
Purpose:
A function to format numbers into my preferred uk format. Could easily be tweaked to add brackets or any text.
Parameters:
telNo
Example:
format.UkTelNumber("01234567890")
returns 01234 567890
format.UkTelNumber("01234567890x123")
returns 01234 567890 x123
Requires Other Custom Functions:
None
Other Notes:
If you are inputting numbers directly use quotes, otherwise the initial 0 will be dropped. When referencing fields make sure they are defined as text.
Definition of _partA can be tweaked as new number formats are released/discovered
Options:
None
*/
Let([
//------------------------- VARIABLES
_number=Substitute(telNo;" ";"");
_second=Middle ( _number ; 2 ; 1 );
_fourth=Middle ( _number ; 4 ; 1 );
_length=Length(_number);
_partA=Case(_second=7;5;_second="1" and _fourth="1";4;_second="8";4;_second="2";3;_second="3";3;5);
_partB=Case(_partA = "3" or _partA="4";3;Min(_length-_partA;6));
_partC= 11-_partA-_PartB;
_extension=_length-11
];
//------------------------- RESULT
Left(_number;_partA) & " " &Middle ( _number;_partA+1; _partB) & " " & Middle ( _number;_partA+_partB+1;_partC)& " " & Middle ( _number;_partA+_partB+_partC+1; _extension)
) // End Let
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/214
Prototype: format.UkTelNumber( telNo )
Function Author: TimA (http://www.fmfunctions.com/mid/102)
Last updated: 03 April 2009
Version: 1
*/
// ===================================
/*__LITBR____LITBR__Name:__LITBR__format.UkTelNumber__LITBR____LITBR__History:__LITBR__Created by Tim Anderson, Tim Anderson Group__LITBR__www.timanderson.co.uk__LITBR__Creation Date: 3 April 2009__LITBR____LITBR__ __LITBR__Purpose: __LITBR__A function to format numbers into my preferred uk format. Could easily be tweaked to add brackets or any text.__LITBR____LITBR__Parameters: __LITBR__telNo__LITBR____LITBR__ __LITBR__Example: __LITBR__format.UkTelNumber("01234567890")__LITBR__returns 01234 567890__LITBR__format.UkTelNumber("01234567890x123")__LITBR__returns 01234 567890 x123__LITBR____LITBR__Requires Other Custom Functions:__LITBR__None__LITBR____LITBR__Other Notes:__LITBR__If you are inputting numbers directly use quotes, otherwise the initial 0 will be dropped. When referencing fields make sure they are defined as text.__LITBR__Definition of _partA can be tweaked as new number formats are released/discovered__LITBR____LITBR__Options:__LITBR__None__LITBR____LITBR____LITBR__*/__LITBR____LITBR__Let([ __LITBR__//------------------------- VARIABLES__LITBR__ _number=Substitute(telNo;" ";"");__LITBR__ _second=Middle ( _number ; 2 ; 1 );__LITBR__ _fourth=Middle ( _number ; 4 ; 1 );__LITBR__ _length=Length(_number);__LITBR__ _partA=Case(_second=7;5;_second="1" and _fourth="1";4;_second="8";4;_second="2";3;_second="3";3;5);__LITBR__ _partB=Case(_partA = "3" or _partA="4";3;Min(_length-_partA;6));__LITBR__ _partC= 11-_partA-_PartB;__LITBR__ _extension=_length-11__LITBR____LITBR__];__LITBR__//------------------------- RESULT__LITBR____LITBR__Left(_number;_partA) & " " &Middle ( _number;_partA+1; _partB) & " " & Middle ( _number;_partA+_partB+1;_partC)& " " & Middle ( _number;_partA+_partB+_partC+1; _extension)__LITBR____LITBR__) // End Let__LITBR____LITBR____LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/214__LITBR____LITBR__ Prototype: format.UkTelNumber( telNo )__LITBR__ Function Author: TimA (http://www.fmfunctions.com/mid/102)__LITBR__ Last updated: 03 April 2009__LITBR__ Version: 1__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.
Comments
10 December 2009
Any ideas??? Thanks