[Asterisk-Users] Conditional Contexts

Steven Critchfield critch at basesys.com
Tue Jul 15 10:12:16 MST 2003


On Tue, 2003-07-15 at 11:52, Derek Beaumont wrote:
> Follow up question:
> Could you explain the following line:
> exten => s,4,GotoIf(${notte}?5:6)
> I really don't know what ?5:6 means.

It is tertiary operator syntax. 
x?y:z is the same as
if(x){ y }else{	z }

> yes, see the db app.
> you can have a main context from which you go to
> context A or B depending on a var stored in the db.
> 
> here's a snippet of my extension.conf
> (I use that to switch into/from 'night' state)
> 
> Inbound calls falls into:
> [inbound]
> exten => s,1,Wait(1)
> exten => s,2,agi,cid_lookup.agi
> exten => s,3,DBget(notte=ServizioNotte/status)
> exten => s,4,GotoIf(${notte}?5:6)
> exten => s,5,Goto(espia_chiuso_full,s,1)
> exten => s,6,Goto(telecom,s,1)
> 
> and in my local context, I can set the status via:
> 
> ;
> ; night service
> ; 7000 enable ; 7001 disable
> ; 7002 get status
> ;
> exten => 7000,1,Authenticate(1234) 
> exten => 7000,2,DBput(ServizioNotte/status=1)
> exten => 7000,3,Hangup
> exten => 7001,1,Authenticate(1234)
> exten => 7001,2,DBput(ServizioNotte/status=0) 
> exten => 7001,3,Hangup
> exten => 7002,1,DBget(notte=ServizioNotte/status)
> exten => 7002,2,Answer
> exten => 7002,3,SayDigits(${notte})
> exten => 7002,4,Hangup
> 
> 
> That's all ;)
> 
> Matteo.
> 
> 
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
-- 
Steven Critchfield  <critch at basesys.com>




More information about the asterisk-users mailing list