Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Program 1

Status
Not open for further replies.

Balarao

MIS
Jun 9, 2003
25
PH
I am writing a program for our raffle promo, I inputed all the numbers for the raffle in my DBF and I wrote a DO WHILE program skipping every record in loop to make it look like a random. However, I can't find a Clipper function or command to get out of the loop! How will go about it or is there a simpler way to make a random procedure.

Thanks again for your help.

God bless,

Balarao
 
hi, yo get out from a Loop, just use the Exit command

Exit = Get out
Loop = branch to begin og loop

Example:

Do While !Eof()
If Recno() == 10
Exit // Get out of Bucle
Endif
DbSkip()
Enddo
 
Generates random number between 1 and whatever nMax is set to. You will need to link the Nanfor53.lib

#include "inkey.ch"
LOCAL nMax := 200
LOCAL nNum
cls
DO WHILE LASTKEY()<>K_ESC

nNum := INT(FT_RAND1(nMax))+1
@1,1 say nNum color &quot;gr+/n&quot;
INKEY(.2)

END DO
 
If you don't have nanfor lib, you can use my little code :)

nNum = TeknoRandom(50) && between 1 and 50

***********************
Function TeknoRandom(nMaxNum)
LOCAL nSeed,TeknoRan
LOCAL m,b
m = 100000000
b = 31415621
nSeed = mod( SECONDS()*b+1, m ) / m
TeknoRan = nMaxNum * nSeed
return( TeknoRan )


Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top