Posted: Wed Apr 04, 2007 12:32 pm Post subject: How to use ALPHANUMERIC as SEQUENTIAL CODE

HI, PEOPLE!
COULD YOU HELP ME ON THIS ONE?....PLEASE..

GENERATE THE TRANSACTION NUMBER CODE THAT COMES AFTER THE LAST ERROR TRANSACTION NUMBER USED IN THE SAME RUN. THE NUMBER CODE SHOULD BE CONTINUOUS FOR EACH RUN. FOR EACH RUN, IT WILL START FROM '1-9' THEN 'A-Z' THEN GOES TO '0' WITH THE NEXT CHARACTER ON THE LEFT INCREMENTING BY 1. THEN THE CHARACTER ON THE RIGHT WILL START AGAIN FROM '1-9' THEN 'A-Z'.
THEN THE CHARACTER ON THE LEFT WILL INCREMENT BY 1 AND THE RIGHT CHARACTER WILL BECOME '0'.

This seems to be a very interesting question. I remember to solve similar one in my Engineering.
This sequence number comsists of 36 symbols. I will call mod 36 number system. ( I am calling it a number system because I perceive this similar similar note to hex - 16, decimal - 10 , octal -8)
I would take some freedom to make change in this NUMBER system as follows.

Quote:

0-9, A-Z, 10-19, .....

This will make our work easy.
Now,
0 in decimal is 0 in mod 36, 1 is 1 and 10 in decimal is A and similarly 35 in decimal is 'Z' in mod 36.
Getting some hint...?

Generate sequence number in decimal only and 'convert' it in to your mod 36 number.

This you can do by dividing decimal number by 36 ( method should be similar to decimal to hex conversion )

Example: 45 in decimal
45/36 = 1
9
So 45 decimal is 19( mod 36)

56 in decimal
56/36 = 1
20 (remainder) = J so 56 (mod 10 ) = 1J (mod 36)

If anyone has different/easier approach, I will eagerly wait for reply.

Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix

Posted: Wed Apr 04, 2007 9:43 pm Post subject:

Hello,

Sounds good to me

As a possible continuation to the posted solution, you might make an array of 1-byte entries that contain the values zero thru zee (0-Z). When you divide by 36, use the remainder of the divide as a displacement into that array to quickly get your mod36 "units" position.