skearton Posted August 10, 2013 Posted August 10, 2013 Hi, I need to be able to take a serial number field and convert to text. like this: 1 = A, 2 = B, 25 = Z, 26 = AA, 27 = BB etc. I did try to use a custom function on brian dunnings website ( http://www.briandunning.com/cf/399 ) but for some reason when I try to save the function Filemaker says "An operator (e.g. +, -, *, ...) is expected here" and it flags the bracket as shown in red below in the code. /* DecToAlpha function Author *COMMENT Visual Realisation Format DecToAlpha ( decimal ) Parameters decimal - any numeric expression or field containing a non-negative numeric expression. NOTE: Only the integer part of decimal will be considered. Data type returned text Description Returns the representation of a decimal number as a variable-length alphabetic text string. January 18, 2006 */ Let ( [ alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; base = Length ( alpha ) ; bit = Mod ( decimal ; base ) ; char = Middle ( alpha ; bit + 1 ; 1 ) ; next = Div ( decimal ; base ) ] ; Case ( next ; DecToAlpha ( next - 1 ) ) & char )
eos Posted August 10, 2013 Posted August 10, 2013 Are you sure that what you pasted here is what you used when trying to create the CF? I copied the text from your post, created a CF from it, and it works as advertised. Â The only things I can think of are a wrong function name (it's recursive, so that must match the name in the calculation), or a missing or misnamed parameter, but both those errors bring up other messages.
Lee Smith Posted August 10, 2013 Posted August 10, 2013 Here is a small sample file showing two of the CFs that do this. I forgot to mention, you can copy the CFs from the file into your by pasting them into your Custom Function Dialog box (File >> Manage >> Custom Functions) skearton.fmp12.zip
skearton Posted August 11, 2013 Author Posted August 11, 2013 Thanks Lee for the file that helps! My problem was I was giving the function name this: "DecToAlpha function" and it had to be just "DecToAlpha". Thanks to you all for the quick help!
Recommended Posts
This topic is 4483 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now