Hi Nav Masters
I have a problems, i need to generate 8 digit Code which each digit is random code consist of : number 2 to 9 (without 0 and 1) or A to Z or a to z
Can we do this?
How to do it in navision c/al code?
Thanks in advance,
______________
Regards,
Steven
0
Comments
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
randomize;
RandomDigit := format(random(7)+2);
but the problem is that randomize needs a seed that is unique every time you call it.
otherwise it uses system time, and so if you call more than once within a second it will return the same value.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Thanks for the reply.
I think the 1st one is great, but what is the : CREATEGUID used for?
I don't understand, can you explain a little?
Ow and one more, random cannot randomize char right?
Thanks
Regards,
Steven
=D> cool idea.
CRATEGUID is generating GUID which is "Globally Unique Identifier". You can google more about that. It is some "code" which you can use as unique, because the chance, that somebody will generate same GUID on the planet is small. It means that the GUID is "random" and the code use this to generate random data and taking some character from the result as random...
Char is just number presented as text. And because you can convert number to char and back, you can "randomize" char... Just random integer and assign it into Char variable...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Instead create a character array that holds all the valid characters. Then generate 8 radom numbers between 1 and the length of the array and add the corresponding array element to your codestring.