[Freeswitch-users] Random number generation

Chris Young Chris.Young at enghouse.com
Tue Jan 24 11:51:12 MSK 2017


Hello all,

On the wiki, there is an example of using mod_expr to generate a random number:

                <!-- generate random number between 1 and 100 -->
                <action application="set" data="rand_val=${expr(randomize(&x);ceil(random(0,100,&x)))}"/>
                <action application="log" data="INFO Random value is ${rand_val}"/>

This works well the first time but if the same dialplan instructions are executed subsequently, the same number is produced each time.

Is this by design? Is there any other way to seed the random number generator so it will produce different results, as randomize() doesn't seem to be doing quite what I thought it would?

Many thanks,
Chris

Chris Young
Software Engineer
[cid:image7482a0.PNG at dc00f514.4fb88205]
t:  +44 118 943 9249
e:  chris.young at enghouse.com<mailto:chris.young at enghouse.com>
w: www.enghouseinteractive.co.uk<http://www.enghouseinteractive.co.uk>
[cid:image6c1ba6.PNG at b8963a35.449174f5]
Enghouse Interactive (UK) Ltd is a company registered in England and Wales. Registered number: 04230977. Registered office: Imperium, Imperial Way, Reading, Berkshire, RG2 0TD

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/4baca23f/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 1045 bytes
Desc: image001.png
Url : http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/4baca23f/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 5097 bytes
Desc: image002.png
Url : http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170124/4baca23f/attachment-0003.png 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list