Tandy 1000 Basic Reference Manual page 287

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10 I
BASIC
Ke.ywords
RANDOMIZE
RANDOMIZE [number]
Function
Reseeds the random number generator.
Number
may be a n integer, or single- or double precision num-
ber.
If
you omit
number,
BASIC suspends program execution and
prompts you for a number before executing RANDOMIZE:
R a n d o m N u m b e r S e e d ( - 3 2 7 6 8 t o 32767)7
If
the random number generator is not reseeded, the RND func-
tion returns the same sequence of numbers each time it is exe-
cuted. To change the sequence of random numbers every time
the RND function is executed, place a RANDOMIZE statement
before the RND function.
You can use the TIMER function to ensure that the random
number generator is reseeded with a different value each time
BASIC executes the RANDOMIZE function. For example, the
statement:
R A N D O M I Z E T I M E R
uses the value returned by TIMER as the seed. TIMER returns
the number of seconds that have elapsed since midnight or the
last system reset. Because the seconds are constantly changing,
number
has a different value each time BASIC executes this
st a t ement
.
Sample Program
1 0
C L S
2 0 R A N D O M I Z E
T I M E R
3 0 I N P U T " P I C K
A
N U M B E R B E T W E E N 1 A N D
1 0 0 " ;
A
40
B
=
I N T < R N D * 1 0 0 )
50
IF A = B T H E N
8 0
6 0
P R I N T
"You
l o s e ,
t h e a n s w e r is"B;"--try
a g a
i
n
.
"
7 0 G O T 0 2 0
8 0
P R I N T
"You p i c k e d t h e right n u m b e r
- -
y o u
win."
285

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents