MAC_Format_Single ( )

Function stats

Average user rating
39
224
9999
Support
FileMaker 7.0 +
Date posted
20 May 2009
Version
1
Recursive function
No

Author Info
 Ender

4 functions

Average Rating None

author_avatar



 

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: 20 May 2009
    Version: 1

*/
// ===================================