Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Auto generate alphanumeric codes
Message
 
 
À
13/03/2000 23:46:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00345198
Message ID:
00345376
Vues:
19
Thanks Fred.

>>I need to programmatically generate and incremented unique alpha-numeric codes 3 characters long. For example, 001,002,003...AAA,AAB,AAC etc. Is there an algorithm that can do this automatically?
>
>If you set a string equal to the characters you want to use say 0-9 and A-Z, you could do this with base36 math.
>
>"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
>
>so 0 would be "000", 1 would be "001", 10 would be "00A", 36 would be "010" and 25000 would be "JAG"
>
>
>d1 = INT(numval/36*36) = 19           (20th character "J")
>d2 = INT((numval-(d1*36*36))/36) = 10 (11th character "A")
>d3 = MOD(numval,36) = 16              (17th character "G")
>
It's "my" world. You're just living in it.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform