random function
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
Hi jerome,
the dITo 3gl toolbox provides (among others) this feature.
See www.uli-merkel.de/dito on SITEMAP look for:
"3TB 3GL Toolbox"
Success, Uli
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
An alternative to the solution offered by Uli is to program a so called "linear congruential generator" in Uniface proc. For example:
variables
numeric Aa, Cee, Em, Xn, Pee
endvariables
Xn = $clock[15:2] ;Random seed
Em = $power(2,32)
Aa = 22695477
Cee = 1
...
while (...)
Xn = (Aa*Xn+Cee)%Em ;Linear Congruential Generator
Pee = Xn /(Em-1) ;Uniformly distributed on [0,1]
...
endwhile
Hans de Vos, Grontmij
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
Hi Hans,
yes, implementing a complete random generator in uniface is an alternative.
Thanks for sharing your code with us.
Some functions have changed it's name in between, so
If one wants to code it in version 7: use power instead of $power
Success, Uli
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
Hi Jérôme
Long time ago, I wrote this procedure on the algorithm by Park&Mille
Ingo
;
;ENTRY GP_RANDOM
;
; Zufallszahlen von 0 bis unterhalb v_MAX erzeuzgen
;
params
numeric v_MAX :IN
numeric v_VALUE :OUT ; erzeugte Zufallszahl
endparams
variables
numeric v_VALUE2
endvariables
call LP_RANDOM(v_VALUE2)
v_VALUE=v_MAX*v_VALUE2
v_VALUE=v_VALUE[trunc]
IF (v_VALUE=v_MAX) v_VALUE=0; Falls $RANDOM$ genau auf 1 stehen sollte
;putmess "Zufall[%%v_MAX] = %%v_VALUE"
RETURN(0)
ENTRY LP_RANDOM
; Nach Park and Miller in ACM June 1988 v32 #6
; http://www.unix-ag.uni-kl.de/~conrad/krypto/misc/prng.html
params
numeric v_VALUE:OUT
endparams
IF($$X_RAND_SEED=""|$$X_RAND_SEED<1)
call LP_RANDOM_INIT
ENDIF
call LP_RANDOM2(v_VALUE)
RETURN(0)
ENTRY LP_RANDOM2
params
numeric v_VALUE:OUT
endparams
variables
numeric v_A
numeric v_M
numeric v_Q
numeric v_R
numeric v_HI
numeric v_LO
numeric v_TEST
endvariables
v_A=16807 ;a
v_M=2147483647 ;m
v_Q=127773 ;q v_M DIV v_A
V_R=2836 ;r v_M MOD v_A
IF ($$X_RAND_SEED<1) $$X_RAND_SEED=1
$$X_RAND_SEED=$$X_RAND_SEED[trunc]
v_HI= $$X_RAND_SEED/v_Q ;hi
v_LO= $$X_RAND_SEED%v_Q ;lo
v_TEST= v_A*v_LO-v_R*v_HI ;test
IF (v_TEST>0)
$$X_RAND_SEED=v_TEST
ELSE
$$X_RAND_SEED=v_TEST+v_M
ENDIF
v_VALUE=$$X_RAND_SEED/v_M
RETURN(0);LP_RANDOM2
ENTRY LP_RANDOM_INIT
variables
numeric v_SEED
numeric v_SEK
endvariables
v_SEED=$time ; Dummerweise nur auf Sekundenbasis
v_SEED=v_SEED[fraction]
v_SEED=v_SEED*1000000
v_SEED=v_SEED[trunc]
v_SEK=v_SEED%10
v_SEED=v_SEED+v_SEK*100+v_SEK*10000
$$X_RAND_SEED=v_SEED
WHILE(v_SEK>0)
v_SEK=v_SEK-1
call LP_RANDOM2(0)
ENDWHILE
RETURN(0)
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
I would like to see this as well -- currently, I call an Oracle procedure to perform this function but would rather do a call native to Uniface.
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
Random ... so often needed and not available :)
Yes, i would like to see this too. Doing web demands some randomizing here and there (e.g. for download-codes, activation stuff and so on).
Nice features could be:
Any other ideas!?
Cheers,
-GHAN-
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
The dIToBox provides a random functionality.
Please have a look at it.
Success, Uli
Author: bignonj@gmail.com (Bignon)
Hi,
How to get a random function in Uniface 7206 ?
Thanks again.
Jérôme
Thanks to all, I have yet to implement the solution but I'll let you know ! Remains to convince the functional office ;-)
Thanks !
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.