Download PICASO Internal 4DGL Functions
Transcript
PICASO INTERNAL 4DGL FUNCTIONS 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2.3.7. RAND() Syntax RAND(); Arguments none Returns value value Returns a pseudo random signed number ranging from -32768 to +32767 each time the function is called. The random number generator may first be seeded by using the SEED(number) function. The seed will generate a pseudo random sequence that is repeatable. You can use the modulo operator (%) to return a number within a certain range, eg n := RAND() % 100; will return a random number between -99 and +99. If you are using random number generation for random graphics points, or only require a positive number set, you will need to use the ABS function so only a positive number is returned, eg: X1 := ABS(RAND() % 100); will set co-ordinate X1 between 0 and 99. Note that if the random number generator is not seeded, the first number returned after reset or power up will be zero. This is normal behavior. Description This function returns a pseudo random signed number ranging from -32768 to +32767 Example SEED(1234); print(RAND(),", ",RAND()); This example will print 3558, 1960 to the display. © 2012 4D SYSTEMS Page 35 of 317 www.4dsystems.com.au