Jump to content
Server Maintenance This Week. ×

convert a serial number to alpha serial


This topic is 3921 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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
)
 
Link to comment
Share on other sites

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.

post-80889-0-24297600-1376175536_thumb.p

post-80889-0-08126500-1376175546_thumb.p

Link to comment
Share on other sites

This topic is 3921 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.