Brian Dunning's FileMaker Custom Functions

Dec2Hex ( theNumber ; num0s )

Convert Decimal # to Hex Text

  Average rating: 3.9 (41 votes) Log in to vote

Samuel Herschbein   Samuel Herschbein
Comsultant
http://www.oz.net/~samh

Share on Facebook Share on Twitter

  Sample input:
Dec2Hex ( 35243 , 6 )
  Sample output:
0089AB

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This custom function requires my other function, listed here only for convenience:

Dec2HexNoLeading0s ( theNumber )
Let (

// get the hex digit for the least significant nibble (4 bits)
thisNibble = Middle ( "0123456789ABCDEF" ; Mod (theNumber ; 16) + 1 ; 1 ) ;

// see if theNumber passed is bigger than a nibble, if so recurse to process the more significant nibbles
If ( theNumber < 16 ;
"" ; // blank means we're not adding any extra
Dec2HexNoLeading0s ( Int ( theNumber / 16 ) ) // add the more significant nibbles
) &
thisNibble // always return the least significant nibble

)

 

Comments

Log in to post comments.

 

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

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth:

Under construction. Email me your wish list for improvements.