[Asterisk-Users] Loops and Variables
Douglas Garstang
dgarstang at oneeighty.com
Mon Feb 20 20:01:23 MST 2006
Eeeeeek!
-----Original Message-----
From: Eric "ManxPower" Wieling [mailto:eric at fnords.org]
Sent: Mon 2/20/2006 11:06 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Cc:
Subject: Re: [Asterisk-Users] Loops and Variables
Douglas Garstang wrote:
> It was trying to perform looping in the dialplan that made me seriously look at AGI. Gee, I wonder what's easier.
>
> This:
> exten => s,1,Set(COUNT=0)
> exten => s,2,Goto(loop,1);this is where we start the loop
> exten => loop,1,GotoIf($[${COUNT} > 5]?next,1);exit if more than 5 esle start again
> exten => loop,2,Set(COUNT=$[${COUNT} + 1])
> exten => loop,3,Goto(1)
> exten => next,1,Noop(${COUNT})
>
> or this...
> loop = 0
> while loop < 5:
> do-something
> loop += 1
>
> I really wasn't enthused about having to look at dialplan code months later and try and work out what I did earlier.
> Nasty!
If you think that's nasty.....
[default]
exten => 3528,1,SetVar(FAX_DEST=arenolds at nowhere.com)
exten => 3528,2,SetVar(DIAL_DEST[1]=SIP/0004f201fbd8-a)
exten => 3528,3,SetVar(DIAL_DEST[2]=SIP/0004f201fbd8-b)
exten => 3528,4,Macro(std-exten)
[macro-std-exten]
exten =>
s,1,AGI(callerid-fixup.agi,${CALLERIDNUM}&${MACRO_EXTEN}&0000000000)
exten => s,2,Noop(AGI(set-ring))
exten => s,3,GotoIf($[${LEN(${FAX_DEST})} = 0]?9:4)
exten => s,4,Cut(TECHNOLOGY=CHANNEL,/,1)
exten => s,5,GotoIf($["${TECHNOLOGY}" = "Zap"]?6:9)
exten => s,6,Answer
exten => s,7,Ringing
exten => s,8,NVFaxDetect(4,d)
exten => s,9,Goto(${MACRO_EXTEN},1)
exten => _XXXX,1,GotoIf($[${LEN(${DIAL_DEST[1]})} = 0]?2:4)
exten => _XXXX,2,GotoIf($[${LEN(${DIAL_DEST})} = 0]?14:3)
exten => _XXXX,3,SetVar(DIAL_DEST[1]=${DIAL_DEST})
exten => _XXXX,4,SetVar(INDEX=1)
exten => _XXXX,5,GotoIf($[${LEN(${DIAL_TIMEOUT[${INDEX}]})} = 0]?6:7)
exten => _XXXX,6,SetVar(DIAL_TIMEOUT[${INDEX}]=20)
exten =>
_XXXX,7,Dial(${DIAL_DEST[${INDEX}]},${DIAL_TIMEOUT[${INDEX}]},${DIAL_OPTS[${INDEX}]}g)
exten => _XXXX,8,GotoIf($["${DIALSTATUS}" = "BUSY" | "${DIALSTATUS}" =
"CHANUNAVAIL" | "${DIALSTATUS}" = "CONGESTION"]?12:9)
exten => _XXXX,9,GotoIf($["${DIALSTATUS}" = "NOANSWER"]?14:10)
exten => _XXXX,10,Noop(DIALSTATUS=${DIALSTATUS})
exten => _XXXX,11,Hangup
exten => _XXXX,12,SetVar(INDEX=$[${INDEX} + 1])
exten => _XXXX,13,GotoIf($[${LEN(${DIAL_DEST[${INDEX}]})} = 0]?14:5)
exten => _XXXX,14,GotoIf($[${LEN(${VOICE_MAILBOX})} = 0]?19:15)
exten => _XXXX,15,Voicemail(${VOICE_MAILBOX})
exten => _XXXX,16,Wait(2)
exten => _XXXX,17,Hangup
exten => _XXXX,18,GotoIf($["${DIALSTATUS}" = "NOANSWER"]?19:22)
exten => _XXXX,19,Voicemail(u${EXTEN})
exten => _XXXX,20,Wait(2)
exten => _XXXX,21,Hangup
exten => _XXXX,22,Voicemail(b${EXTEN})
exten => _XXXX,23,Wait(2)
exten => _XXXX,24,Hangup
exten => _XXXX,116,AbsoluteTimeout(30)
exten => _XXXX,117,Playback(sorry-mailbox-full)
exten => _XXXX,118,Wait(2)
exten => _XXXX,119,Congestion
exten => _XXXX,120,Goto(116)
exten => _XXXX,123,Goto(116)
exten => talk,1,Goto(${MACRO_EXTEN},1)
exten => fax,1,Cut(FAX_TECH=FAX_DEST,/,1)
exten => fax,2,GotoIf($["${FAX_TECH}" = "Zap"]?3:7)
exten => fax,3,Dial(${FAX_DEST},20)
exten => fax,4,AbsoluteTimeout(30)
exten => fax,5,Wait(2)
exten => fax,6,Congestion
exten => fax,7,RxFax(/tmp/fax-${UNIQUEID}.tiff)
exten =>
fax,8,DeadAGI(/usr/local/bin/fax2email.pl,/tmp/fax-${UNIQUEID}.tiff)
exten => fax,9,Hangup
exten => fax,104,AbsoluteTimeout(30)
exten => fax,105,Busy
exten => a,1,Playback(/etc/asterisk/directvm)
exten => a,2,VoicemailMain()
exten => a,3,Wait(.5)
exten => a,4,Goto(1)
exten => o,1,GotoIf($[${LEN(${OPER_DEST})} = 0]?2:4)
exten => o,2,Goto(extensions,0,1)
exten => o,3,Hangup
exten => o,4,GotoIf($[${OPER_TIMEOUT} = 0]?5:6)
exten => o,5,SetVar(OPER_TIMEOUT=)
exten => o,6,GotoIf($[${LEN(${OPER_MESSAGE})} = 0]?8:7)
exten => o,7,Playback(${OPER_MESSAGE})
exten => o,8,Dial(${OPER_DEST},${OPER_TIMEOUT},${OPER_FLAGS})
exten => o,9,Voicemail(u${MACRO_EXTEN})
exten => o,10,Hangup
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 7198 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20060220/aebec02c/attachment.bin
More information about the asterisk-users
mailing list