cls ? random() ? random(10) ? random(100) ? random(1000) ? random(10000) ? random(10000) ? ? StrZero( Random( 100000000 ), 8 ) + ".TXT" //------------------------------------------------------------------------------ #include "Common.Ch" #define PERIOD 2147483647 #define FACTOR 16807 FUNCTION Random( nMaxVal ) /* Returns a floating-point pseudo-random number between 0 and maxval (left-inclusive), with maxval defaulting to 1. If maxval is in the same order of size as the generator's period, the distribution of the resulting PRNs will be irregular, but since PERIOD is 2147483647, that should not be a problem in practice; people doing astrophysics or monte carlo simulation using Clipper deserve everything they get, anyway . */ Local nRandom Static nSeed := 0 DEFAULT nMaxVal TO 1 While nSeed == 0 nSeed := Seconds() nSeed :=( nSeed * 12345 ) % PERIOD Enddo nSeed := FACTOR * nSeed - Int(FACTOR * nSeed / PERIOD ) * PERIOD If ValType(nMaxVal) == "N" nRandom := nSeed / ( PERIOD / nMaxVal + 1 ) Else nRandom := nSeed / PERIOD Endif RETURN nRandom //------------------------------------------------------------------------------