[Home]

Summary:ASTERISK-04698: AEL parsing IF-Else incorrectly
Reporter:tgledhill (tgledhill)Labels:
Date Opened:2005-07-26 21:52:54Date Closed:2005-07-26 22:00:11
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Functions/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:‘IF’ branches are not always parsed correctly. Example:

If("${ACCEPT}" = "1") {
           SayNumber(2);
           System(/bin/rm ${uniqueid});
       } else
           SayNumber(3);
           MACRO_RESULT=CONTINUE;

Gets parsed into:

6. Goto(${IF($[ "${ACCEPT}" = "1" ]?7:9)})    [pbx_ael]
7. SayNumber(2)                               [pbx_ael]
8. System(/bin/rm ${uniqueid})                [pbx_ael]
9. NoOp(Finish if-screen-6)                   [pbx_ael]
10. Set(MACRO_RESULT=$[ CONTINUE ])           [pbx_ael]

Instead of ending at priority 8 it continues on through priorities 9 and 10. The fix for this is to force the dialplan to take the right path. Example:

If("${ACCEPT}" = "1") {
           SayNumber(2);
           System(/bin/rm ${uniqueid});
           goto end;
       } else
           SayNumber(3);
           MACRO_RESULT=CONTINUE;
   end:
       NoOp(finished-macro-screen);

Parsed into:

6. Goto(${IF($[ "${ACCEPT}" = "1" ]?7:10)})   [pbx_ael]
7. SayNumber(2)                               [pbx_ael]
8. System(/bin/rm ${uniqueid})                [pbx_ael]
9. Goto(end)                                  [pbx_ael]
10. NoOp(Finish if-screen-6)                  [pbx_ael]
11. Set(MACRO_RESULT=$[ CONTINUE ])           [pbx_ael]
    [end]          12. NoOp(finished-macro-screen)               [pbx_ael]
Comments:By: Clod Patry (junky) 2005-07-26 21:56:01

what about if u include ur { } after the else?
Also, make sure a bug doesn't already exists before reporting a new bug.
Thanks.