I
I
ilchenkoa2016-06-08 11:31:38
Asterisk
ilchenkoa, 2016-06-08 11:31:38

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 ;

In selecting sw, I need to loop, i.e. go back up.
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;
}

How can the transition be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ilchenkoa, 2016-06-08
@ilchenkoa

Decided with the help of labels and goto.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question