hexxabubba Posted April 19, 2008 Posted April 19, 2008 Any good methods to generate random alpha-numeric numbers? Certificate Field=7 digit number set by script.User determines start number and amount of records to generate.This number must be unique... Each series will be 10,000 number increments. Unless someone sticks a 100,000 in there... So I guess it doesn't matter if pin is unique but it would be nice... Pin Field=6 digit random numeric. =auto-enter calc =Right("000000" & Random* 999999; 6) I want the pin to be alpha numeric... Thanks in Advance!
comment Posted April 19, 2008 Posted April 19, 2008 The requirements for random AND unique are somewhat conflicting. You would need to generate a random number, check it against all previously generated numbers, and reject it if there is a collision. As the amount of generated numbers grows, the system slows down. It seems to me a serially incrementing number would be a better choice for numbering certificates. To generate a random alpha-numeric code from any alphabet: Let ( [ alpha = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ] ; Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1) & Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1) & Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1) & Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1) & Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1) & Middle ( alpha ; Ceiling ( Random * Length ( alpha ) ) ; 1) )
Greenman Posted November 11, 2008 Posted November 11, 2008 I used this and an error capture on commit to attempt to create a script to create a unique six-character id. However, even after the script finishes, I get an error that says there is an existing id. It takes a few tries to get a unique id that will actually work. I've got ten seats using the same host, and only 2 of 10 seats are wiggy about the script. I get a system error that says a unique id with that number already exists. And it does. This doesn't happen on the other machines. All using FM9. Is it possible that there is a random seed generation problem here? Is it possible that since there is no 'while' method that the seed is only checked for the first instance? I may be entirely chasing down the wrong avenue. If someone could produce an example script that will check to make sure my id is both valid and unique, I'd be grateful.
comment Posted November 11, 2008 Posted November 11, 2008 First and foremost: this is NOT a good method to create unique IDs. I don't know why you're having an issue with 2 particular seats. No one knows how the Random() function works internally - not even FMI engineers, it seems: http://fmforums.com/forum/showtopic.php?tid/195627/post/299804/#299804 since there is no 'while' method Not sure what you mean by that. If the process is scripted, you can loop until a condition is met - I believe that qualifies as a 'while' method. If you have Advanced, you can also write a recursive custom function that will do the same.
Greenman Posted November 11, 2008 Posted November 11, 2008 comment, Thanks for your reply. I would appreciate any suggestions you may have for creating a six-character random unique id. We need a short id, but numbers-only would run out in a couple years if we just auto-incremented.
comment Posted November 11, 2008 Posted November 11, 2008 As I said before, unique and random do not go well together. I'd suggest you use an auto-entered serial number as the basic ID. If you want a shorter code, just convert the numeric ID to a higher base, e.g. using "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" would enable you to go up to base 36. See also: http://www.briandunning.com/cf/218
Greenman Posted November 11, 2008 Posted November 11, 2008 That would have been my next question. I appreciate your psychic abilities. I think I can take it from here. This is better. Cheers!
Recommended Posts
This topic is 5915 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now