Page 1 of 1
RANDOMIZE
Posted: Thu Jan 31, 2013 10:24 am
by Silvio.Falconi
I have a dbf with some record and I must take a record from this archive but on randomize
How I can make ?
Re: RANDOMIZE
Posted: Thu Jan 31, 2013 10:49 am
by sambomb
Select YOURDBF
DbGoTo( nRandom(LastRec()-1)+1 )
nRandom is 0 to nParam
LastRec() is your total recs
You need the -1 on LastRec to compensate the 0 start from nRandom and the +1 is to compensate the -1
Re: RANDOMIZE
Posted: Thu Jan 31, 2013 12:48 pm
by Silvio.Falconi
NRANDOM HAVE PROBLEM
i REMEMBER THERE WAS ANOTHER WITH HB_
Re: RANDOMIZE
Posted: Thu Jan 31, 2013 1:11 pm
by BeoBeo
Why u cry
Re: RANDOMIZE
Posted: Thu Jan 31, 2013 1:42 pm
by sambomb
I never had a problem with nRandom, but...
DbGoTo( HB_Random(1, LastRec() ) ) should solve too.
Re: RANDOMIZE
Posted: Thu Jan 31, 2013 2:56 pm
by James Bott
I think you are going to need to convert the values to integers.
And, I assume for what you want you will need to generate an array so you can check for duplicates and not add them. You are looking to create an array of unique values.
James