<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Hi Srigo,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Thanks for your help. Unfortunately, I still see the same value getting generated each time the extension gets executed e.g.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"> 51a7a226-27e6-4fe3-979b-0b0bb28253d9 2017-01-24 09:49:21.504783 [INFO] mod_dptools.c:1628 Random value is 1<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">70aae2dc-cee6-4a3c-805f-5655abd7e6e6 2017-01-24 09:49:21.965642 [INFO] mod_dptools.c:1628 Random value is
1<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:36.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">92e81c00-0ff0-4ddc-819f-019c145f39be 2017-01-24 09:49:22.444287 [INFO] mod_dptools.c:1628 Random value is
1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">I take it that from-core is some context you've defined in your environment rather than anything special, as it didn't work when I
used that (so I changed it to 'default')?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Chris<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org]
<b>On Behalf Of </b>KSrigo<br>
<b>Sent:</b> 24 January 2017 09:14<br>
<b>To:</b> FreeSWITCH Users Help <freeswitch-users@lists.freeswitch.org><br>
<b>Subject:</b> Re: [Freeswitch-users] Random number generation<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi Chris,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I’m not sure if I understood exactly your needs. This is how I use randomize function:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Define Random Number Generator extension:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><extension name="random_number_gen" continue="true"><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <condition field="destination_number" expression="^random_number_gen$" break="never"><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <!-- generate random number between 1 and 100 --><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <action application="set" data="rand_val=${expr(randomize(&x);ceil(random(0,100,&x)))}" inline="true"/><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <action application="log" data="INFO Random value is ${rand_val}"/><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> </condition><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"></extension><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">then call it in your diaplan each time you need to get a random number set:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><action application="execute_extension" data="random_number_gen XML from-core"/><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Srigo<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Jan 24, 2017, at 9:51 AM, Chris Young <<a href="mailto:Chris.Young@enghouse.com">Chris.Young@enghouse.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Hello all,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">On the wiki, there is an example of using mod_expr to generate a random number:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <!-- generate random number between 1 and 100 --><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <action application="set" data="rand_val=${expr(randomize(&x);ceil(random(0,100,&x)))}"/><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <action application="log" data="INFO Random value is ${rand_val}"/><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">This works well the first time but if the same dialplan instructions are executed subsequently, the same number is produced each time.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">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?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Many thanks,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Chris<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:13.5pt;font-family:"Calibri",sans-serif;color:#00559A">Chris Young</span><span class="apple-converted-space"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> </span></span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><br>
<span style="color:dodgerblue">Software Engineer</span><span style="color:#00A0DC"><br>
<image001.png><br>
</span><span style="color:#00559A">t:</span> <span style="color:dodgerblue">+44 118 943 9249</span><span style="color:#00559A"><br>
e:</span> <span class="apple-converted-space"> </span><span style="color:dodgerblue"><a href="mailto:chris.young@enghouse.com"><span style="color:#0563C1">chris.young@enghouse.com</span></a></span><span style="color:#00559A"><br>
w:</span><span class="apple-converted-space"> </span><span style="color:dodgerblue"><a href="http://www.enghouseinteractive.co.uk/" title="Enghouse Interactive"><span style="color:dodgerblue">www.enghouseinteractive.co.uk</span></a></span><span style="color:#00B0F0"><br>
<image002.png></span><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="margin-top:6.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#A6A6A6">Enghouse Interactive (UK) Ltd is a company registered in England and Wales. Registered number: 04230977. Registered office: Imperium,
Imperial Way, Reading, Berkshire, RG2 0TD</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<span class="apple-converted-space"> </span><br>
</span><a href="mailto:consulting@freeswitch.org"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72">consulting@freeswitch.org</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
</span><a href="http://www.freeswitchsolutions.com/"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72">http://www.freeswitchsolutions.com</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
<br>
Official FreeSWITCH Sites<br>
</span><a href="http://www.freeswitch.org/"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72">http://www.freeswitch.org</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
</span><a href="http://confluence.freeswitch.org/"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72">http://confluence.freeswitch.org</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
</span><a href="http://www.cluecon.com/"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72">http://www.cluecon.com</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
<br>
FreeSWITCH-users mailing list<br>
</span><a href="mailto:FreeSWITCH-users@lists.freeswitch.org"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72">FreeSWITCH-users@lists.freeswitch.org</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
</span><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
UNSUBSCRIBE:http://</span><a href="http://lists.freeswitch.org/mailman/options/freeswitch-users"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72">lists.freeswitch.org/mailman/options/freeswitch-users</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
</span><a href="http://www.freeswitch.org/"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72">http://www.freeswitch.org</span></a><o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>