RANDOMIZE

RANDOMIZE

Postby Silvio.Falconi » Thu Jan 31, 2013 10:24 am

I have a dbf with some record and I must take a record from this archive but on randomize
How I can make ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: RANDOMIZE

Postby sambomb » Thu Jan 31, 2013 10:49 am

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
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: RANDOMIZE

Postby Silvio.Falconi » Thu Jan 31, 2013 12:48 pm

NRANDOM HAVE PROBLEM
i REMEMBER THERE WAS ANOTHER WITH HB_
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: RANDOMIZE

Postby BeoBeo » Thu Jan 31, 2013 1:11 pm

Why u cry
BeoBeo
 
Posts: 6
Joined: Tue Oct 09, 2012 9:59 am

Re: RANDOMIZE

Postby sambomb » Thu Jan 31, 2013 1:42 pm

I never had a problem with nRandom, but...

DbGoTo( HB_Random(1, LastRec() ) ) should solve too.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: RANDOMIZE

Postby James Bott » Thu Jan 31, 2013 2:56 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 103 guests