Page 1 of 1

random with a dbf

Posted: Sat Apr 15, 2006 4:27 pm
by Silvio
I have a dbf where there is a field ( codice)
how I can load an random number to load a record


Regards

Posted: Sat Apr 15, 2006 5:02 pm
by Antonio Linares
You may use nRandom( <nRange> ) --> nValue to create random numbers.

Posted: Sat Apr 15, 2006 10:34 pm
by Silvio
thanks antonio
but this func is of fw or harbour ?

Posted: Sat Apr 15, 2006 11:15 pm
by Antonio Linares
FW/FWH

Posted: Sun Apr 16, 2006 2:38 am
by Sakis
Silvio

Try the folowing:

Code: Select all


FUNCTION  Unique()

LOCAL cNumeric:=   STR (HB_RANDOMINT(1,10000) ,5) 

// You may use any number instand of 10000

cNumeric := STRTRAN (cNumeric ," ","0")

RETURN( cNumeric)

 
Regards
Dionisis

Posted: Sun Apr 16, 2006 4:32 pm
by Silvio
thanks but I must create a random number from a file dbf
on the file dbf i have a numeric field ( codice) :

use IMG alias IMG
totale:= img->(reccount())
Number:=nRnadom(totale)
Go Number

have you another idea ?

Posted: Sun Apr 16, 2006 6:39 pm
by Sakis
Hello Silvio again

Try the following :

Code: Select all


FUNCTION Unique(nTotale)

RETURN( HB_RANDOMINT(1,nTotale))

Regards
Dionisis

Posted: Sun Apr 16, 2006 8:57 pm
by Silvio
thanks to all