Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

convert a serial number to alpha serial

Featured Replies

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
)
 
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

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

  • Author

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!

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.