<< Click to Display Table of Contents >> Navigation: 3. Script Language > Mathematical and algorithmic operations > Mathematical and algorithmic operations |
MiniRobotLanguage (MRL)
RND. Command
RaNDom number
Intention
This command can be used to get random numbers within a known range.
Using RND. without any parameter will Re-Seed the internal RND-Generator.
The internal Random number generator will always return the same sequence of random numbers. If you do not want this, just add a
RND.
at the start of your script. This will re-seed the random number generator and start a new practically unpredictable random number sequence.
Syntax
RND.[P1][|P2][|P3]
Parameter Explanation
P1 - minimum value (can be negative), variable or formula in (..).
P2 - Maximum Value (can be negative), variable or formula in (..).
P3 - Variable to return the Random-Value.If omitted Value is been
placed on TOS.
Example
'*************************************
' RND - DEMO
'*************************************
' Re-Seed the RND-numbers generator
' do this to prevent to always get the same sequence of
' random numbers.
RND.
FOR.$$AAA|1|20
' Generate Random Numbers between 1 and 9
RND.1|9|$$REB
PRT.[$$AAA]->$$REB|d
NEX.
END.
'*************************************
' RND - DEMO 2
'*************************************
'DBM.2
FOR.$$AAA|1|20
RND.-3|-1|$$REB
PRT.[$$AAA]->$$REB|d
NEX.
END.
Remarks:
The Parameter P1 can be negative, for example, if you want Random-Numbers between 5 and 5.
Limitations:
This is not a cryptographic/scientific random number generator.
See also:
• CAL. - mathematical CALculation
• VAR. - Variable Set Value/Clear