2 Replies Latest reply on Mar 22, 2013 11:14 AM by philmodjunk

# unique id-code generator

### Title

unique id-code generator

### Post

Hi, I am searching a very helpful function for any field biologist... I would like to generate color ring code. I have 7 possible colors and I will put three rings. I am also differentiating females from males with the ringing. Example: M/B/B/B (A male with three black rings) F/B/W/G (A female with a black ring, a white ring and a grey ring) I would like that the function give me a unique code each time I make a new record. Obviously the code should be unique! The color can be given randomly but the first letter should be depend on the sex I am defining. Any idea of a script? Thank you! Nicolas

• ###### 1. Re: unique id-code generator

Can a male and a female both get the same color combination or is the three ring combination unique for each regardless of gender?

Either way, you are working with a fairly limited set of unique codes (343 or 686). I suggest generating a table of all possible color combinations and assigning a code from the next record (or the next record for the indicated gender if different sex individuals can have the same color banding), in the table.

With 7 colors, you essentially have a base seven number with colors being used as "digits" so we can use a base ten serial number in this table and translate it into base 7 to get the corresponding color code. If different sexed individuals can have the same color combo, you'd do this twice, once for each gender.

The calculations from the serial numbers might work like this:

Let ( [ N = SerialNumberField ;
D1 = Mod ( N ; 7 ) ;
D2 = Mod ( Div ( N ; 7 ) ; 7 ) ;
D3 = Mod ( Div ( Div ( N ; 7 ) ; 7 ) ; 7 ) ];
Choose ( D3 ;  "Black" ; "Red" ; "Blue" ; "Orange" ; "Yellow" ; "White" ; "Green" ) & "/" &
Choose ( D2 ; "Black" ; "Red" ; "Blue" ; "Orange" ; "Yellow" ; "White" ; "Green" ) & "/" &
Choose ( D1 ; "Black" ; "Red" ; "Blue" ; "Orange" ; "Yellow" ; "White" ; "Green" )
)

• ###### 2. Re: unique id-code generator

Note that the first serial number value should be zero, not the 1 you get with the default serial number auto-enter settings.