[Asterisk-Users] after hours - is this logic ok ?
Tilghman Lesher
tilghman at mail.jeffandtilghman.com
Thu Jan 1 10:36:25 MST 2004
On Wednesday 31 December 2003 19:16, Lance Arbuckle wrote:
> Andrew Thompson wrote:
> > ----- Original Message -----
> > From: "Lance Arbuckle" <asterisk at arbuckle.org>
> > >
> > > Before I get too excited, I wanted to get all you experts to look
> > > at the how I implemented my after hours test. The goal is to
> > > prevent the phone from ringing afer certain hours, just go to VM.
<snip>
> [day]
> exten => s,2,DBput(FEATURE/DAY=yes)
> exten => s,3,Goto(s,10)
>
> [night]
> exten => s,2,DBdel(FEATURE/DAY) ;if we got here it must be night
> time so remove the key
> exten => s,3,Goto(s,10)
>
> [macro-stdexten]
> exten => s,1,NoOp
> < other testing crap deleted >
> exten => s,10,DBget(foo=FEATURE/DAY) ; is it day time ? if key
> exists, goto n+1, otherwise n+101
> exten => s,11,Goto(s,201) ; yes, well let's ring the phones
> exten => s,111,Goto(s,204) ; no, goto uVM
I'm curious as to why you're going the extra step to put a value into
the database. Why not just set a channel variable and check that value?
[day]
exten => s,2,SetVar(daytime=1)
[night]
exten => s,2,SetVar(daytime=0)
[macro-stdexten]
exten => s,10,GotoIf($[${daytime}]?11:111)
Using a variable is nice, because all channels get their own variable
space, so there's no chance of collisions between different calls, and
the variable is automatically trashed when the channel is hungup.
-Tilghman
More information about the asterisk-users
mailing list