need help randomizing on GWBASIC 
Author Message
 need help randomizing on GWBASIC

Does anyone know of a way to randomize on GWBASIC.

I am using the rnd() function, but everytime I run I get the same set of
numbers.

I have misplaced my book and I think it is in a box in the garage. Haven't
used it in 3-4 years.

Thanks in advance for the help.....

Bob



Mon, 24 May 2004 14:24:41 GMT  
 need help randomizing on GWBASIC

Quote:
> Does anyone know of a way to randomize on GWBASIC.

> I am using the rnd() function, but everytime I run I get the same set of
> numbers.

> I have misplaced my book and I think it is in a box in the garage. Haven't
> used it in 3-4 years.

RANDOMIZE TIMER

You had the right command in your description of the problem!  8-)

Tom Lake



Mon, 24 May 2004 14:31:51 GMT  
 need help randomizing on GWBASIC
Thanks Tom - Works great.
- Bob


Quote:
> > Does anyone know of a way to randomize on GWBASIC.

> > I am using the rnd() function, but everytime I run I get the same set of
> > numbers.

> > I have misplaced my book and I think it is in a box in the garage.
Haven't
> > used it in 3-4 years.

> RANDOMIZE TIMER

> You had the right command in your description of the problem!  8-)

> Tom Lake



Mon, 24 May 2004 14:43:25 GMT  
 need help randomizing on GWBASIC
On Thu, 06 Dec 2001 06:24:41 GMT, "Robert Nolan"

Quote:

>Does anyone know of a way to randomize on GWBASIC.

>I am using the rnd() function, but everytime I run I get the same set of
>numbers.

>I have misplaced my book and I think it is in a box in the garage. Haven't
>used it in 3-4 years.

Before your first call to RND(), execute a
RANDOMIZE TIMER
statement.  The pseudorandom number generator needs a "seed" value to
start the sequence, and the default seed is a constant.  RANDOMIZE
reseeds the generator with the number you specify.  Using TIMER (which
holds the number of seconde since the last clock rollover, which may
or may not have been last midnight) is the standard way to get an
unpredictable sequence.


Mon, 24 May 2004 15:19:17 GMT  
 need help randomizing on GWBASIC

Quote:
> Does anyone know of a way to randomize on GWBASIC.

> I am using the rnd() function, but everytime I run I get the same set of
> numbers.

While others have pointed out how to get different numbers each time, the
fact that RND() generates the same set of numbers when the same "seed" value
is used is a great way to generate test data and to recreate that data when
errors are found in testing.

NumberofTestValues = 1000   'change as desired
SeedValue               =  2        'change this to generate a new set of
numbers or leave alone to recreate the series

RANDOMIZE SeedValue
FOR I = 1 to NumberOfTestValues
    TestValue (I) = RND
 NEXT

FOR I = 1 to numberoftestvalues
    CALL functiontobetested (TestValue(I))
NEXT

MCM



Mon, 24 May 2004 19:26:55 GMT  
 need help randomizing on GWBASIC


Quote:
> Does anyone know of a way to randomize on >GWBASIC.
> I am using the rnd() function, but everytime I run I >et the same set of
numbers.
> I have misplaced my book and I think it is in a box in >he garage. Haven't

used it in 3-4 years.

Randomize Timer

Put that at the start of your program. It only needs to
be executed 1 time in your program.
  Time to get that book out. <g>



Tue, 25 May 2004 00:07:53 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Need help with RANDOMIZE/RND

2. I need help on randomizing variables

3. Need Help with Randomize

4. Desperate - need help with Randomize

5. Help need GWBASIC interpretation

6. HELP : I REALLY NEED GWBASIC.COM

7. need help for gwbasic

8. Help Needed -- GWBASIC unprotect?

9. Need help compiling gwbasic/qbasic code

10. Doorst: need help with GWBASIC/QBASIC

11. GWBASIC - HELP NEEDED - FOLLOW-UP

12. GWBASIC PROBLEM - HELP NEEDED

 

 
Powered by phpBB® Forum Software