Shopping Cart

Search:

Signup

Contact

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

FileMaker Pro Custom Functions

NumToDuoTrigesimal ( number )

Rate this function:

Discuss this Custom Function

Tim Griffith, None
None

Converts a number into a duotrigesimal (base32) string

Sample Input:
 NumToDuoTrigesimal ( 123456789 )
Sample Output:
 3NQK8N

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

Description:

NumToDuoTrigesimal ( number )

No dependencies

( to convert Duotrigesimal strings back to numbers use custom function DuoTrigesimalToNum ( DTGString ) )

Created: December 26, 2010 St. Louis, MO USA

Tim Griffith Sr.

Duotrigesimal, or base 32 numbers are like Hexadecimal numbers in that after 9, numbers are represented by letters. We know we can't use all the letters of the alphabet because the index of numbers would go beyond 31 up to 35. As best I have discovered the letters 'I' 'L' and 'O' are not used because in various forms they can be mistaken for other characters. My research has also shown that the letter 'U' has been omited because of 'accidental obscenities'.
Throughout books and the internet there are numerous algorithms showing how to convert numbers to hex and hex to numbers. I am not a genius, but rather a bit clever enough to augment those formulas to add the additional letters beyong hex F, and substitute dividing or multplying 16 into 32. All in all it was quite simple.
If credit is due- then it is due to those many people who have provided hex to num formulas. Thank you all- you know who you are!

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:

You could make it more portable (easy to change the allowed character set and quantity) by not hard-coding the number of characters in your base. Just do the following:

Let ( [
_ALPH = "0123456789ABCDEFGHJKMNPQRSTVWXYZ" ;
_BASE = Mod ( number ; Length( _ALPH ) ) ;
_CHAR = Middle ( _ALPH ; _BASE + 1 ; 1 ) ;
_NEXT = Div ( number ; Length( _ALPH ) )
] ;

Case (
_NEXT ;
NumToDuoTrigesimal ( _NEXT )
)//end Case
& _CHAR
)//end Let

Or to make it incredibly portable, make the "base string" (your _ALPH variable) be a parameter, and name the function BaseConvert( baseString, decimalNumber ).

Daniel A. Shockley, New York, NY
January 13, 2011 11:25am

Where baseString is used instead of _ALPH in the custom function, and decimalNumber is used instead of number to make it clear that the number must be in decimal, not some other custom base).

Daniel A. Shockley, New York, NY
January 13, 2011 11:27am

Thanks Daniel, very inspired thinking on your part- I should have seen this- but I was so connected to the idea of of a cf for for base 32 that I missed the logic of the simpler solution. I am going to work this and post it.

Tim Griffith, St. Louis, MO USA
January 13, 2011 1:34pm

Daniel, OK, the conversion you noted from number to BASEx was very easy indeed- just as you stated. However, converting back from a BASEx presents lots of extra programmed reasoning- in that, allowing the user to create any BASE system, you will end up with letters in positions that will have to be calculated, ie. A will not always be the 10th character etc. Plus, a user BASE might also allow juxtaposing alpha and numeric, such as character set = 01BFT74K983D5. Sure this can be worked out, but not as elegantly as just dealing with an accepted standard base system.
So, to create a custom BASEx conversion-- follow Daniels inspired observations. I tried it, it worked well. As far as a reverse conversion- I'll let another wise person out there figure it out. I think there is already an 'any base' cf on the list, so there might also be the reverse conversion there also. I am currently very busy with an HL7 parser.

Tim Griffith, St. Louis
January 13, 2011 5:17pm

Tim, we ended up adapting your original function to allow for any base conversion ( BaseX_FromDecimal: https://www.briandunning.com/cf/2051 ). I also created a function to allow for conversion back to decimal, provided the same baseString is used ( BaseX_ToDecimal: https://www.briandunning.com/cf/2052 ).

Erik Shagdar, New York, NY
June 20, 2017 9:38am