<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Here is an example:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>[macro-now-stdexten]<BR>Exten =>
s,1,Playback(transfer)<BR>Exten => s,2,GotoIf($[${ARG1} = 501 | ${ARG1} = 520
| ${ARG1} = 522 ${ARG1} = 537]?3:10)<BR>Exten =>
s,3,Macro(nowque,${ARG1})<BR>Exten =>
s,10,Dial(SIP/${ARG1},30,t) ; Ring the
interface, 22 seconds maximum<BR>Exten => s,11,Voicemail(<A
href="mailto:u${ARG1}@nowtech">u${ARG1}@nowtech</A>)
; If unavailable, send to voicemail w/ unavail announce<BR>Exten =>
s,12,Hangup<BR>Exten =>
s,112,Voicemail(b${ARG1}nowtech)
; If busy, send to voicemail w/ busy announce<BR>Exten =>
s,113,Hangup</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=ncfm@airmail.net href="mailto:ncfm@airmail.net">Ed Devine</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=asterisk-users@lists.digium.com
href="mailto:asterisk-users@lists.digium.com">asterisk-users@lists.digium.com</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, April 27, 2004 5:51
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Asterisk-Users] parsing to
compare</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>Admittedly this is probably pretty stupid of me,
but there are just some things I can't understand by reading documentation.
Any suggestions or recommendations about how to handle my problem are greatly
appreciated. I'm trying to achieve the same functionality as my Nortel PBX,
without rewriting much 'C' code.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In my dialplan I'd like to compare two variables
as a means of getting around some of the troubles I've experienced in
authenticating users, or with using Disa (primarily the requirement that a '#'
be sent to terminate the authorization field). One variable
(AUTHCODE shown below) is a series of digits entered by
the caller once asterisk has answered and returned dialtone. I want to
compare this variable to a variable already stored in ${CIDNAME} and,
depending on the results of the comparison (i.e. if it's a match
proceed, if not or if no value or '0' is found, branch to another context or
simply to jump to an extension in the present context, or hangup</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Everytime I've tried (using gotoif as an example)
I get a parsing error; or the program allows everything through.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Think of the process as being like Disa, except
you don't send the '#'</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I've been noodling around with code that is
pretty much as follows:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>[main2]</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>exten =>
_XXXXXXX9XXXXXXXXXX,1,SetVar(AUTHCODE=${EXTEN:0:7})</FONT></DIV>
<DIV><FONT face=Arial size=2>'Calls coming in to '*' from outside are
answered and sent here. The Caller recieves
PlayInterruptibleTones(dial)</FONT></DIV>
<DIV><FONT face=Arial size=2>'and begins entering digits. The first seven are
moved to the AUTHCODE variable for comparison.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>exten =>
_XXXXXXX9XXXXXXXXXX,2,dbget(${CIDNAME} ${AUTHCODE})</FONT></DIV>
<DIV><FONT face=Arial size=2>'I do a dbget to retrieve the CIDNAME if one
exists that matches AUTHCODE</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>exten =>
_XXXXXXX9XXXXXXXXXX,3,SetCIDName(${CIDNAME})</FONT></DIV>
<DIV><FONT face=Arial size=2>'I do this just so I don't have to screw around
with the ast_expr.y: error or implementing </FONT></DIV>
<DIV><FONT face=Arial size=2>'the 'foo trick' to test for an empty value when
using GoToif.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>exten =>
_XXXXXXX9XXXXXXXXXX,4,Gotoif(${CIDNAME} = 228XXXX)?|1:5</FONT></DIV>
<DIV><FONT face=Arial size=2>'This is just one of the seemingly hundreds of
options I've tried just to see if</FONT></DIV>
<DIV><FONT face=Arial size=2>'I could get the Gotoif to pass the call if it
met the requirements, or fail if it didn't</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>exten =>
_XXXXXXX9XXXXXXXXXX,5,dial(zap/g3/${EXTEN:7:18})</FONT></DIV>
<DIV><FONT face=Arial size=2>'This is where I send the actual called number
digits to the channel</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>exten =>
_XXXXXXX9XXXXXXXXXX,6,hangup</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>exten => s,1,answer</FONT></DIV>
<DIV><FONT face=Arial size=2>exten =>
s,2,Playinterruptibletones(dial)</FONT></DIV>
<DIV><FONT face=Arial size=2>exten => i,1,Congestion</FONT></DIV>
<DIV><FONT face=Arial size=2>exten => i,2,Hangup</FONT></DIV>
<DIV><FONT face=Arial size=2>exten => t,1,Congestion</FONT></DIV>
<DIV><FONT face=Arial size=2>exten =>
t,2,Hangup</FONT></DIV></BLOCKQUOTE></BODY></HTML>