<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Asterisk 1.4:  Numbers Guessing Game</title>
	<atom:link href="http://www.voipphreak.ca/2006/12/03/asterisk-howto-numbers-guessing-game/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.voipphreak.ca/2006/12/03/asterisk-howto-numbers-guessing-game/</link>
	<description>Cool sh!t about Asterisk, VOIP, XMPP 'n stuff</description>
	<lastBuildDate>Wed, 26 Oct 2011 14:49:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: flewid</title>
		<link>http://www.voipphreak.ca/2006/12/03/asterisk-howto-numbers-guessing-game/comment-page-1/#comment-18</link>
		<dc:creator>flewid</dc:creator>
		<pubDate>Tue, 05 Dec 2006 20:02:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.voipphreak.ca/archives/323#comment-18</guid>
		<description>Awesome. Thanks!</description>
		<content:encoded><![CDATA[<p>Awesome. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Murphy</title>
		<link>http://www.voipphreak.ca/2006/12/03/asterisk-howto-numbers-guessing-game/comment-page-1/#comment-17</link>
		<dc:creator>Steve Murphy</dc:creator>
		<pubDate>Tue, 05 Dec 2006 19:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.voipphreak.ca/archives/323#comment-17</guid>
		<description>Hello--

I suppose this is grossly obsessive-compulsive, but I took a few minutes and translated the above extensions.conf into AEL.

---- cut here ---------file=guessit.ael------------------------------
macro guessgame()
{
        while (1)
        {
                Playback(guessit/intro);
                set(GUESS=&quot;&quot;);
                GUESS=${EPOCH}%9;
                Set(TIMEOUT(digit)=3);
                Set(TIMEOUT(response)=5);
                while (1)
                {
                        Read(NUMBER,guessit/input_number,1);
                        Verbose(Got ${NUMBER} from Read);
                        if( &quot;${NUMBER}&quot; = &quot;*&quot; &#124;&#124; &quot;${NUMBER}&quot; = &quot;#&quot; &#124;&#124; &quot;${NUMBER}&quot; = &quot;&quot;)
                        {
                                Playback(guessit/thatsnotanumber);
                        }
                        else if (&quot;${NUMBER}&quot; = &quot;${GUESS}&quot;)
                        {
                                Playback(guessit/win);
                                break; // the only way out of this loop!
                        }
                        else if (&quot;${NUMBER}&quot; &gt; &quot;${GUESS}&quot;)
                        {
                                Playback(guessit/less);
                        }
                        else if (&quot;${NUMBER}&quot; &lt; &quot;${GUESS}&quot;)
                        {
                                Playback(guessit/more);
                        }
                        else /* what other stuff can the user enter than a number, #, nothing, or * ? */
                        {
                                Playback(guessit/thatsnotanumber);
                        }
                }
                /* You get here after a successful guess */
                Wait(.5);
                Read(AGAIN,guessit/playagain,1);
                if (&quot;${AGAIN}&quot; != &quot;1&quot;)
                        break;
        }
        Playback(guessit/goodbye);
        return;

        catch t
        {
                playback(guessit/goodbye);
                return;
        }
        catch i
        {
                playblack(invalid);
        }
}
---------------------------- cut here ----------------------

Put the above into the file, guessit.ael in /etc/asterisk.

Then in your extensions.ael, outside a context, slip in this include:

#include &quot;guessit.ael&quot;


and in some context enter in the macro call from an appropriate extension:

        779 =&gt; {
                &amp;guessgame();
        }

In the above, dialing 779 will trigger the game.

All these instructions apply to 1.4 and trunk versions of Asterisk. For those running 1.2, I suggest making a 1.2 patch, and installing AEL2. It most likely will not work on the original AEL code that comes with 1.2.

I wrote the code as an example, it has no goto&#039;s. It implements the game as nested loops. I will also post it on the voip-info asterisk wiki in the AEL examples page.

There are some slight variations from the original code...

murf</description>
		<content:encoded><![CDATA[<p>Hello&#8211;</p>
<p>I suppose this is grossly obsessive-compulsive, but I took a few minutes and translated the above extensions.conf into AEL.</p>
<p>&#8212;- cut here &#8212;&#8212;&#8212;file=guessit.ael&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
macro guessgame()<br />
{<br />
        while (1)<br />
        {<br />
                Playback(guessit/intro);<br />
                set(GUESS=&#8221;");<br />
                GUESS=${EPOCH}%9;<br />
                Set(TIMEOUT(digit)=3);<br />
                Set(TIMEOUT(response)=5);<br />
                while (1)<br />
                {<br />
                        Read(NUMBER,guessit/input_number,1);<br />
                        Verbose(Got ${NUMBER} from Read);<br />
                        if( &#8220;${NUMBER}&#8221; = &#8220;*&#8221; || &#8220;${NUMBER}&#8221; = &#8220;#&#8221; || &#8220;${NUMBER}&#8221; = &#8220;&#8221;)<br />
                        {<br />
                                Playback(guessit/thatsnotanumber);<br />
                        }<br />
                        else if (&#8220;${NUMBER}&#8221; = &#8220;${GUESS}&#8221;)<br />
                        {<br />
                                Playback(guessit/win);<br />
                                break; // the only way out of this loop!<br />
                        }<br />
                        else if (&#8220;${NUMBER}&#8221; > &#8220;${GUESS}&#8221;)<br />
                        {<br />
                                Playback(guessit/less);<br />
                        }<br />
                        else if (&#8220;${NUMBER}&#8221; < "${GUESS}")<br />
                        {<br />
                                Playback(guessit/more);<br />
                        }<br />
                        else /* what other stuff can the user enter than a number, #, nothing, or * ? */<br />
                        {<br />
                                Playback(guessit/thatsnotanumber);<br />
                        }<br />
                }<br />
                /* You get here after a successful guess */<br />
                Wait(.5);<br />
                Read(AGAIN,guessit/playagain,1);<br />
                if ("${AGAIN}" != "1")<br />
                        break;<br />
        }<br />
        Playback(guessit/goodbye);<br />
        return;</p>
<p>        catch t<br />
        {<br />
                playback(guessit/goodbye);<br />
                return;<br />
        }<br />
        catch i<br />
        {<br />
                playblack(invalid);<br />
        }<br />
}<br />
---------------------------- cut here ----------------------</p>
<p>Put the above into the file, guessit.ael in /etc/asterisk.</p>
<p>Then in your extensions.ael, outside a context, slip in this include:</p>
<p>#include "guessit.ael"</p>
<p>and in some context enter in the macro call from an appropriate extension:</p>
<p>        779 => {<br />
                &#038;guessgame();<br />
        }</p>
<p>In the above, dialing 779 will trigger the game.</p>
<p>All these instructions apply to 1.4 and trunk versions of Asterisk. For those running 1.2, I suggest making a 1.2 patch, and installing AEL2. It most likely will not work on the original AEL code that comes with 1.2.</p>
<p>I wrote the code as an example, it has no goto&#8217;s. It implements the game as nested loops. I will also post it on the voip-info asterisk wiki in the AEL examples page.</p>
<p>There are some slight variations from the original code&#8230;</p>
<p>murf</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Gibson</title>
		<link>http://www.voipphreak.ca/2006/12/03/asterisk-howto-numbers-guessing-game/comment-page-1/#comment-16</link>
		<dc:creator>Matt Gibson</dc:creator>
		<pubDate>Tue, 05 Dec 2006 00:12:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.voipphreak.ca/archives/323#comment-16</guid>
		<description>Hi Someone, 

Thanks for the note. I meant reload, not restart. The howto has been updated to reflect the proper wording :)

Good catch!

Thanks,
voipphreak</description>
		<content:encoded><![CDATA[<p>Hi Someone, </p>
<p>Thanks for the note. I meant reload, not restart. The howto has been updated to reflect the proper wording :)</p>
<p>Good catch!</p>
<p>Thanks,<br />
voipphreak</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Someone</title>
		<link>http://www.voipphreak.ca/2006/12/03/asterisk-howto-numbers-guessing-game/comment-page-1/#comment-32</link>
		<dc:creator>Someone</dc:creator>
		<pubDate>Mon, 04 Dec 2006 21:52:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.voipphreak.ca/archives/323#comment-32</guid>
		<description>At step 6, no need to restart, a reload will do
You know, this is not Windows ;-)</description>
		<content:encoded><![CDATA[<p>At step 6, no need to restart, a reload will do<br />
You know, this is not Windows ;-)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: www.voipphreak.ca @ 2012-02-07 19:24:58 -->
