Answer the question
In order to leave comments, you need to log in
How to jump to the beginning of a macro in ael?
Hello! I found a macro suitable for my tasks on the Internet and I'm trying to translate it into ael format. Faced the problem of returning to the very beginning of the macro.
[macro-gsm]
exten => s,1(start),Set(ARG2=$[${ARG2} + 1]);
same => n,GotoIf($[${ARG2}>=9005]?sip:repeat);
same => n(repeat),MYSQL(Connect connid localhost asterisk password asterisk);
same => n,MYSQL(Query resultid ${connid} SELECT SUM(`billsec`) FROM `cdr` WHERE `dstchannel` LIKE '%${ARG2}%' AND `calldate` BETWEEN DATE_FORMAT(NOW(),'%Y-%m-01') AND LAST_DAY(NOW()) + INTERVAL 1 DAY) ;
same => n,MYSQL(Fetch fetchid ${resultid} duration) ;
same => n,MYSQL(Clear ${resultid}) ;
same => n,MYSQL(Disconnect ${connid})
same => n,GotoIf($[${duration}<=18000]?call:start) ;
same => n(call),Set(limit=$[18000 - ${duration}]) ;
same => n,Dial(SIP/${ARG2}/${ARG1},,S(${limit})tTr) ;
same => n,GotoIf($[${DIALSTATUS}=ANSWER]?finish:start) ;
same => n(sip),Dial(SIP/ctm/${ARG1},,Ttr) ;
same => n(finish),Hangup ;
macro test( ext, trk ) {
Set(trk=$[${trk} + 1]);
GotoIf($[${trk}>=9005]?sip:repeat);
repeat:
MYSQL(Connect connid localhost asterisk password asterisk);
MYSQL(Query resultid ${connid} SELECT SUM(`billsec`) FROM `cdr` WHERE `dstchannel` LIKE '%${trk}%' AND `calldate` BETWEEN DATE_FORMAT(NOW(),'%Y-%m-01') AND LAST_DAY(NOW()) + INTERVAL 1 DAY);
MYSQL(Fetch fetchid ${resultid} duration);
MYSQL(Clear ${resultid});
MYSQL(Disconnect ${connid});
Noop(${duration});
GotoIf($["${duration}" <= "50"]?wll:sw);
wll:
Set(limit=$[50 - ${duration}]);
Dial(SIP/${ext}@${trk},,S(${limit})tTr);
sw:
????
sip:
Dial(SIP/${ext}@provider,60);
Hangup;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question