HB_RandomSeed()

HB_RandomSeed()
   Sets the seed for generating random numbers.

Syntax :

   HB_RandomSeed( [<nSeed>] ) --> NIL

Arguments :
   <nSeed> : A numeric value used as seed for generating the random 
    numbers returned by HB_Random() and HB_RandomInt(). 
 
Return :
 
   The function returns always NIL. 
 
Description :
 This function sets the seed value for generating random numbers 
  with HB_Random() and HB_RandomInt(). 

  When a seed value is specified for the random number generator, 
  it produces the same series of  random numbers with each program 
  invocation. This is useful for debugging purposes. 
 
  Calling the function without an argument resets the seed so that 
  HB_Random() and HB_RandomInt() generate different series of random 
  numbers each time a program is executed. 
 
See also: HB_Random(), HB_RandomInt()
Example :

PROCEDURE Main
   LOCAL i, cStr1 := Space(10), cStr2 := Space(10)
   HB_RandomSeed(7)
   FOR i:=1 TO Len( cStr1 )
       cStr1[i] := HB_RandomInt(65,90)
   NEXT
   ? HB_RandomSeed()
   FOR i:=1 TO Len( cStr2 )
      cStr2[i] := HB_RandomInt(65,90)
   NEXT
   ? cStr1
   ? cStr2
 RETURN
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s