Kontrollnummer_EAN ( )

Function stats

Average user rating
328
319
9999
Support
FileMaker 10.0 +
Date posted
06 January 2012
Version
1
Recursive function
No

Author Info
 Ronny

1 functions

Average Rating None

author_avatar



 

Function overview

Prototype

Kontrollnummer_EAN  ( EAN_Enhet )


Parameters

EAN_Enhet  First 12 numbers in the EAN-string


Description

Tags:  EAN  

The last number in EAN-13 ( European Article Number) is an checksum depending on the preview 12 numbers. This function calculate this number for you.

Examples

Sample input

739371455827


Sample output

5

 

Function code

If ( Length ( EAN_Enhet ) = 12 ;

(
(
Ceiling (
(
(
(
Middle ( EAN_Enhet ; 2 ;1 ) +
Middle ( EAN_Enhet ; 4 ;1 ) +
Middle ( EAN_Enhet ; 6 ;1 ) +
Middle ( EAN_Enhet ; 8 ;1 ) +
Middle ( EAN_Enhet ; 10 ;1 ) +
Middle ( EAN_Enhet ; 12 ;1 )
) * 3
) +
(
Left ( EAN_Enhet ; 1 ) +
Middle ( EAN_Enhet ; 3 ;1 ) +
Middle ( EAN_Enhet ; 5 ;1 ) +
Middle ( EAN_Enhet ; 7 ;1 ) +
Middle ( EAN_Enhet ; 9 ;1 ) +
Middle ( EAN_Enhet ; 11 ;1 )
)
) / 10
)
) * 10
)
-
(
(
(
Middle ( EAN_Enhet ; 2 ;1 ) +
Middle ( EAN_Enhet ; 4 ;1 ) +
Middle ( EAN_Enhet ; 6 ;1 ) +
Middle ( EAN_Enhet ; 8 ;1 ) +
Middle ( EAN_Enhet ; 10 ;1 ) +
Middle ( EAN_Enhet ; 12 ;1 )
) * 3
) +
(
Left ( EAN_Enhet ; 1 ) +
Middle ( EAN_Enhet ; 3 ;1 ) +
Middle ( EAN_Enhet ; 5 ;1 ) +
Middle ( EAN_Enhet ; 7 ;1 ) +
Middle ( EAN_Enhet ; 9 ;1 ) +
Middle ( EAN_Enhet ; 11 ;1 )
)
)

; "" )

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/319

    Prototype: Kontrollnummer_EAN( EAN_Enhet )
    Function Author: Ronny (http://www.fmfunctions.com/mid/328)
    Last updated: 06 January 2012
    Version: 1

*/
// ===================================

 

Comments

comment
13 February 2012



Couldn't this be simpler? For example =

Mod (
-3 * Sum (
Middle ( EAN ; 2 ;1 ) ;
Middle ( EAN ; 4 ;1 ) ;
Middle ( EAN ; 6 ;1 ) ;
Middle ( EAN ; 8 ;1 ) ;
Middle ( EAN ; 10 ;1 ) ;
Middle ( EAN ; 12 ;1 )
) - Sum (
Left ( EAN ; 1 ) ;
Middle ( EAN ; 3 ;1 ) ;
Middle ( EAN ; 5 ;1 ) ;
Middle ( EAN ; 7 ;1 ) ;
Middle ( EAN ; 9 ;1 ) ;
Middle ( EAN ; 11 ;1 )
) ; 10 )
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (31)
Date  (26)
List  (25)
Format  (23)
XML  (22)
Sql  (18)
Dev  (17)
Debug  (14)
Text  (13)
Variables  (12)
Interface  (12)
Layout  (11)
Filter  (10)
Design  (9)
Array  (7)
Layout Objects  (7)