[asterisk-users] 99 bottles of beer
David Boyd
dboyd at ignitetrx.com
Fri Aug 17 06:42:53 CDT 2007
On Thu, 2007-08-16 at 19:38 -0600, Steve Murphy wrote:
> On Thu, 2007-08-16 at 07:56 -0400, Russell Bryant wrote:
> > Gordon Henderson wrote:
> > > ; *99:
> > > ; 99 bottles of beer on the wall.
> > >
> > > exten => *99,1,Noop(99 Bottles of beer on the wall)
> > > exten => *99,n,Answer()
> > > exten => *99,n,Set(bottles=99)
> > > exten => *99,n(loop),Noop(There are ${bottles} bottles of beer on the wall)
> > > exten => *99,n,SayNumber(${bottles})
> > > exten => *99,n,Noop(Take one done and pass it round and there's)
> > > exten => *99,n,Set(bottles=$[${bottles}-1])
> > > exten => *99,n,Noop(${bottles} bottles of beer on the wall)
> > > exten => *99,n,SayNumber(${bottles})
> > > exten => *99,n,GotoIf($["${bottles}" > "0"]?loop)
> > > exten => *99,n,Noop(We're out of beer!)
> > > exten => *99,n,Hangup()
> > >
> > > Too much dial plan mashing this morning and I rememberd this site:
> > >
> > > http://99-bottles-of-beer.net/
> >
> > And now, in AEL! (This is untested, I just wanted to see how it would look.)
> >
> > context silly {
> > *99 => {
> > NoOp(99 Bottles of beer on the wall);
> > Answer();
> > bottles=99;
> > while (${bottles} > 0) {
> > NoOp(${bottles} bottles of beer on the wall, ${bottles} bottles of beer);
> > SayNumber(${bottles});
> > NoOp(Take one down, pass it around);
> > bottles=${bottles} - 1;
> > NoOp(${bottles} bottles of beer on the wall);
> > }
> > NoOp(We're out of beer!);
> > Hangup();
> > }
> > }
>
> Lol, Well done, Russell!
>
> How about this one: from an extensions.conf that someone posted on the
> internet, I think, and I converted to AEL; I'm sorry, but I can't find
> the original author.
> (If anybody can find his post, I'd love to give him credit.) I did test
> this out,
> and it works; just put a call to the macro ( &guessgame(); ) in an
> extension in your dialplan....
>
>
> macro guessgame()
> {
> startpoint:
> while (1)
> {
> Playback(guessit/intro);
> set(GUESS="");
> 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( "${NUMBER}" = "*" || "${NUMBER}" = "#" || "${NUMBER}" = "")
> {
> Playback(guessit/thatsnotanumber);
> }
> else if ("${NUMBER}" = "${GUESS}")
> {
> Playback(guessit/win);
> break; // the only way out of this loop!
> }
> else if ("${NUMBER}" > "${GUESS}")
> {
> Playback(guessit/less);
> }
> else if ("${NUMBER}" < "${GUESS}")
> {
> 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 ("${AGAIN}" != "1")
> break;
> }
> Playback(guessit/goodbye);
> return;
>
> catch t
> {
> playback(guessit/goodbye);
> return;
> }
> catch i
> {
> playblack(invalid);
> }
> }
>
> murf
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
Hey murf,
here is the link for the credit,
http://www.voipphreak.ca/archives/358-Asterisk-Howto-Numbers-Guessing-Game.html
its also in the wiki examples.
http://www.voip-info.org/wiki/view/AEL+Example+Snippets
db
More information about the asterisk-users
mailing list