Important: The information in this document is obsolete and should not be used for new development.
Random
You can use theRandom
function to obtain a pseudorandom integer.
FUNCTION Random: Integer;DESCRIPTION
TheRandom
function returns a pseudorandom integer, uniformly distributed in the range -32767 to 32767.The value
Random
returns depends solely on the global variablerandSeed
, which the QuickDrawInitGraf
procedure initializes to 1. Each time theRandom
function executes, it uses a numerical algorithm to change the value ofrandSeed
to prevent it from returning the same value each time it is called.To prevent your application from generating the same sequence of pseudo-random numbers each time it is executed, initialize the
randSeed
global variable, when your application starts up, to a volatile long word variable such as the current date and time. If you would like to generate the same sequence of pseudo-random numbers twice, on the other hand, simply setrandSeed
to the same value before callingRandom
for each sequence.ASSEMBLY-LANGUAGE INFORMATION
You can access the global variablerandSeed
through the system global variableRndSeed
.SEE ALSO
Listing 3-5 on page 3-22, Listing 3-6 on page 3-23, Listing 3-7 on page 3-23,
and Listing 3-8 on page 3-24 for examples of how to use theRandom
function.