From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC


This function sets the starting point of the random number generator, RND() (seeding the generator).
Using same value, this will always return the same set of random numbers with each run of the program (great for debugging).


  1. RANDOMIZE Number
The Number must be in the range of 0 < n < 1.
It is sometimes referred to as random seed.


If you do NOT issue RANDOMIZE command, JB supposed to start from random number (contrary to QBasic, that always started with same number)
There were reports that restarting JB and not issuing RANDOMIZE gives numbers close on the same sequence. If it is important to you, you should seed generator yourself.
When you don't seed the generator, it appears to continue the sequence from the previous run (the seed is stored somewhere).
Small changes in seed used with RANDOMIZE very likely lead to small changes in next RND value.
Workaround: After while, sequences will run apart. So if you just discard some next 10 random numbers, that will take care of it.


' print a different set of numbers for each run
For i = 1 To 10
    Print INT(RND(0)*10) + 1
Print "---"
' print the same set of numbers for each run
Randomize 0.5
For i = 1 To 10
    Print INT(RND(0)*10) + 1

Useful Procedures

' Place a useful function or sub using this keyword here