RE: Random number in 4gl
Posted in 1996
Bill, 4gl doesn't have a built in random number generator, as you have guessed, so your only chance is to write one in c, and call that from within 4gl. Enclosed find my own. ---------------- cut here crndc.c ----------------- #include <stdio.h> unsigned int seed=1; /* ** gets next random number */ get_rand(nargs) int nargs; { long i,j; popint(&i); seed=(0x8088405*seed+1) & 0xFFFF; j=seed % i; retint(j); return(1); } /* ** sets the random generator seed */ start_rand(nargs) int nargs; { int i; popint(&i); seed=i; return(0); } /* ** returns the current seed */ say_seed(nargs) int nargs; { retint(seed); return(1); } /* ** asks the system clock for a seed */ get_seed(nargs) int nargs; { int i; i=(time(NULL)) & 0xFFFF; retint(i); return(1); } -------------------- end cut --------------------------- HTH, Marco ____________________________________________________________________________ rem radioterapia, which I immeritately manage, seldom agrees with what I say marco greco (Catania, Italy) Work: marcog@ctonline.it rem radioterapia 39 95 447828 fax 446558 (was mar.greco@agora.stm.it) Achea 39 95 503117 --- On Mon, 18 Nov 96 16:15:00 EST "Katelis, Bill" <BKatelis@vibupls1.telstra.com.au> wrote: Hi, Does anyone know of a random number generator in 4gl (Informix? (Not using c func call) Thanks bill bkatelis@vibupls1.telecom.com.au -----------------End of Original Message-----------------