I've found in the past that Navision's random number generator is not as "random" as I would have expected. This could mean that you're loop may end up repeating too many times if there are a lot of random numbers generated that are less then or equal to 7.
This way to generate numbers is very similar in all languages. Some languages had just random generator generating numbers between 0 and 1. It means, if you wanted to have numbers from range 10..90 you needed to do
Answers
RndmNumber := RANDOM(4) + 8 should do nicely
yours was the easy approach lol
i came up with a long way, not sure if its acceptable?!
IF RndmNumber <8 THEN
REPEAT
RANDOMIZE;
RndmNumber := RANDOM(12);
UNTIL RndmNumber >7;
I've found in the past that Navision's random number generator is not as "random" as I would have expected. This could mean that you're loop may end up repeating too many times if there are a lot of random numbers generated that are less then or equal to 7.
Epimatic Corp.
http://www.epimatic.com
Excellence in simplicity, I like that one
RIS Plus, LLC
8)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
i did think that the loop may end up looping continually if the random number never went over 7!!
So went for
RANDOM(5) + 7; (so that 8 is given a chance)!
The easy way round this would be to use FORMAT.
Have a function create the random number you want, and then FORMAT(Number)