[Asterisk-Users] parsing to compare

Glenn Dalgliesh asterisk at techhat.com
Tue Apr 27 14:48:21 MST 2004


Here is an example:

[macro-now-stdexten]
Exten => s,1,Playback(transfer)
Exten => s,2,GotoIf($[${ARG1} = 501 | ${ARG1} = 520 | ${ARG1} = 522 ${ARG1} = 537]?3:10)
Exten => s,3,Macro(nowque,${ARG1})
Exten => s,10,Dial(SIP/${ARG1},30,t)        ; Ring the interface, 22 seconds maximum
Exten => s,11,Voicemail(u${ARG1}@nowtech)           ; If unavailable, send to voicemail w/ unavail announce
Exten => s,12,Hangup
Exten => s,112,Voicemail(b${ARG1}nowtech)         ; If busy, send to voicemail w/ busy announce
Exten => s,113,Hangup


----- Original Message ----- 
  From: Ed Devine 
  To: asterisk-users at lists.digium.com 
  Sent: Tuesday, April 27, 2004 5:51 PM
  Subject: [Asterisk-Users] parsing to compare


  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.

  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

  Everytime I've tried (using gotoif as an example) I get a parsing error; or the program allows everything through.

  Think of the process as being like Disa, except you don't send the '#'

  I've been noodling around with code that is pretty much as follows:

  [main2]

  exten => _XXXXXXX9XXXXXXXXXX,1,SetVar(AUTHCODE=${EXTEN:0:7})
  'Calls coming in to '*' from outside are answered and sent here. The Caller recieves PlayInterruptibleTones(dial)
  'and begins entering digits. The first seven are moved to the AUTHCODE variable for comparison.

  exten => _XXXXXXX9XXXXXXXXXX,2,dbget(${CIDNAME} ${AUTHCODE})
  'I do a dbget to retrieve the CIDNAME if one exists that matches AUTHCODE

  exten => _XXXXXXX9XXXXXXXXXX,3,SetCIDName(${CIDNAME})
  'I do this just so I don't have to screw around with the ast_expr.y: error or implementing 
  'the 'foo trick' to test for an empty value when using GoToif.

  exten => _XXXXXXX9XXXXXXXXXX,4,Gotoif(${CIDNAME} = 228XXXX)?|1:5
  'This is just one of the seemingly hundreds of options I've tried just to see if
  'I could get the Gotoif to pass the call if it met the requirements, or fail if it didn't

  exten => _XXXXXXX9XXXXXXXXXX,5,dial(zap/g3/${EXTEN:7:18})
  'This is where I send the actual called number digits to the channel

  exten => _XXXXXXX9XXXXXXXXXX,6,hangup

  exten => s,1,answer
  exten => s,2,Playinterruptibletones(dial)
  exten => i,1,Congestion
  exten => i,2,Hangup
  exten => t,1,Congestion
  exten => t,2,Hangup
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20040427/7912611c/attachment.htm


More information about the asterisk-users mailing list