RandomYou can use the
Randomfunction to obtain a pseudorandom integer.
FUNCTION Random: Integer;
Randomfunction returns a pseudorandom integer, uniformly distributed in the range -32767 to 32767.
Randomreturns depends solely on the global variable
randSeed, which the QuickDraw
InitGrafprocedure initializes to 1. Each time the
Randomfunction executes, it uses a numerical algorithm to change the value of
randSeedto 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
randSeedglobal 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 set
randSeedto the same value before calling
Randomfor each sequence.
ASSEMBLY-LANGUAGE INFORMATIONYou can access the global variable
randSeedthrough the system global variable
SEE ALSOListing 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 the