Older Newer
Tue, 31 Dec 2019 09:54:25 . . . . SyneRyder [Tweak example code formatting]


Changes by last author:

Added:
= srand =

== Syntax ==

void srand(int seed)

== Arguments ==

:seed

::An integer value that seeds (initializes) the random number generator.

== Description ==

srand seeds the pseudo-random number generator functions. If you seed the generator with a known value, the same sequence of 'random' numbers will occur each time after being seeded with that value. This is useful if you need reproducible but still random-seeming values (eg if you want a graphics effect preset that seems to behave randomly, but can be shared with others to give the same result).

== Example ==

<code>

%fml

ctl[0]: STANDARD, Text="Seed Value"

ctl[5]: STATICTEXT, Text="", Size=(160,*)

// Changing slider zero gives

// different random numbers, but

// the same numbers each time for

// each specific setting

OnFilterStart: {

srand(ctl(0));

sprintf(str1, "'Random' values: %d, %d, %d", rand(), rand(), rand());

setCtlText(5, str1);

return true;

}

</code>

== See Also ==

rnd, rand