Function overview
Prototype
MAC_Format_Single (
text )
Parameters
text
Description
Tags:
NIC MAC Format
The MAC Address is the Ethernet hardware address of a NIC card or wireless card. This CF formats it into six octets separated by the designated separator (a colon).
For entries that are missing characters, the CF appends placeholders colored in red for easy recognition.
For entries that are too long, the extra characters are kept, but highlighted in red for easy recognition.
Examples
Sample input
a1b2c3d4e5f6g7
Sample output
A1:B2:C3:D4:E5:F6G7
[G7 would be highlighted in red]
Function code
//MAC_Format_Single(text)
//by Ender
//Formats a single MAC address in the format: AA:BB:CC:DD:EE:FF
//Handles addresses with six octets
Let(
[
t1 = Filter(Upper(text);"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
t2 = Case(Length(t1)≤12 and Length(t1)>0;
Left(TextColor(t1;RGB ( 0 ; 0 ; 0 ) ) & TextColor ( "xxxxxxxxxxxxxx" ; RGB ( 255 ; 10 ; 10 ) ); 12);
Length(t1)>12;
TextColor(Left(t1;12); RGB ( 0 ; 0 ; 0 ) ) & TextColor ( Middle(t1; 13; 100) ; RGB ( 255 ; 10 ; 10 ))
);
separator = ":"
];
Middle(t2;1;2) & separator & Middle(t2;3;2) & separator & Middle(t2;5;2) & separator & Middle(t2;7;2) & separator & Middle(t2;9;2) & separator & Middle(t2;11;2) & Case(Length(t2)>12; Middle(t2; 13; 100))
)
// ===================================
/*
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/224
Prototype: MAC_Format_Single( text )
Function Author: Ender (http://www.fmfunctions.com/mid/39)
Last updated: 19 May 2009
Version: 1
*/
// ===================================
//MAC_Format_Single(text)__LITBR__//by Ender__LITBR____LITBR__//Formats a single MAC address in the format: AA:BB:CC:DD:EE:FF__LITBR__//Handles addresses with six octets__LITBR____LITBR____LITBR__Let(__LITBR__[__LITBR__ t1 = Filter(Upper(text);"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");__LITBR__ t2 = Case(Length(t1)≤12 and Length(t1)>0; __LITBR__ Left(TextColor(t1;RGB ( 0 ; 0 ; 0 ) ) & TextColor ( "xxxxxxxxxxxxxx" ; RGB ( 255 ; 10 ; 10 ) ); 12);__LITBR__ Length(t1)>12; __LITBR__ TextColor(Left(t1;12); RGB ( 0 ; 0 ; 0 ) ) & TextColor ( Middle(t1; 13; 100) ; RGB ( 255 ; 10 ; 10 ))__LITBR__ );__LITBR__ separator = ":"__LITBR__];__LITBR____LITBR__Middle(t2;1;2) & separator & Middle(t2;3;2) & separator & Middle(t2;5;2) & separator & Middle(t2;7;2) & separator & Middle(t2;9;2) & separator & Middle(t2;11;2) & Case(Length(t2)>12; Middle(t2; 13; 100))__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/224__LITBR____LITBR__ Prototype: MAC_Format_Single( text )__LITBR__ Function Author: Ender (http://www.fmfunctions.com/mid/39)__LITBR__ Last updated: 19 May 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.