Hi Chris,
Once I wrote a function which generates
an unique number and it works fine for me.
Here's the code:
/* Randdemo.prg
Demonstrates the randomgen-function
Needs xBase Tools III
xpp randdemo /q/ w
alink randdemo
Written by: Chris van Reeven */
#pragma Library("xbtbase1.lib")
#pragma Library("xbtbase2.lib")
PROCEDURE MAIN()
LOCAL i, np := sqrt( (0.5+rand(0)) ), cTxt
cTxt := "random"+ substr(TIME(),7,2)
SET ALTERNATE TO (cTxt)
SET ALTERNATE ON
// Generate 100 values with the unique
<np>-seed
For i := 1 TO 100
?STR(RANDOMGEN( np ),15,10)
NEXT
SET ALTERNATE OFF
SET ALTERNATE TO
RETURN
************************************************************************
FUNCTION RANDOMGEN(np)
**********************
/* The function RANDOMGEN(np) needs
as incoming parameter <np> a for each
range of figures once generated
startvalue <np> which is formed by
np := sqrt( (0.5+rand(0)) ) */
LOCAL n, nq
n := rand()
nq := n*np
nq := IF(nq>1, 1-(nq-1), nq)
RETURN nq
************************************************************************
Hope this will help you.
Best regards,
Chris (the other one)
Hello
If I run this procedure . . .
clear
! time
12:00 ///
resetting the system clock to 12:00
for aaa = 1 to
20
bbb = random()
?
bbb
next
. . . . I get the same 20 random
numbers everytime, is there any other method of getting a random
number without using the clock (a long shot I know).
If not, could somebody please explain
what part of the clock is used - i.e. 100'th of a second, 1000's
etc
Any Info would be usefull
Thanks
Chris