*****************************************************
** FUNCTION NAME ... GenRand
** Author .......... Subramanian.G, FoxAcc
** .......... ramani_g@yahoo.com
** Purpose ......... Generates required number of
** Unique random numbers (nHowMany)
** between the nLow & nHigh passed
** HowRun........... DO GenRand WITH nHigh,nLow,nHowMany
** ... or..... =GenRand(nHigh,nLow,nHowMany)
*****************************************************
FUNCTION GenRand
PARAMETERS nLow, nHigh, nHowMany
PUBLIC nRandArray(nHowMany)
** Exit the function if improperly called
IF PARAMETERS() < 3
WAIT "PARAMETERS ERROR"
RETURN .f.
ENDIF
IF nLow > nHigh OR nHowMany < 1
WAIT "PARAMETERS ERROR"
RETURN .f.
ENDIF
**
LOCAL nMyRand, nCount, nDuplicate
nCount = 1
nDuplicate = 0
DO WHILE nCount < nHowMany
nMyRAND = INT(((nHigh-nLow+1)* RAND() ) + nLow)
nDuplicate = ASCAN(nRandArray,nMyRand)
IF nDuplicate # 0
LOOP
ENDIF
nRandArray(nCount) = nMyRand
nCount=nCount+1
ENDDO
RETURN .t.
*****************************************************
** EOF
*****************************************************
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com