_srand Function

Purpose

Sets a random starting point.

Syntax

_srand(seed)

seed : ivar

Description

The C-compatible _srand function sets the starting point for generating a series of pseudorandom integers. To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the generator to a random starting point. _rand retrieves the pseudorandom numbers that are generated. Calling _rand before any call to _srand generates the same sequence as calling _srand with seed passed as 1.

_srand(qTimer) or _srand(oTimer) give good random starting values.

Example

Global x

~_srand(oTimer) // seed

x = _rand()

MsgBox x

Remarks

To create a random value GFA-BASIC 32 uses the 'C'-randomizer, which doesn't need the Randomize command to initialize the generator, but instead uses _srand.

_rand() is faster than Rand(), but doesn't have the longer period as Rand().

See Also

_rand, _srand, Rand, Randomize, Random, Rnd, qTimer, oTimer

{Created by Sjouke Hamstra; Last updated: 23/09/2014 by James Gaite}