Not escapable character "open parenthesis"


#1

We all know how to escape characters, but what happens if one of those pesky characters is coming from the outside, like in the body of an SMS? What happens if you need to pass that character in a macro? Asterisk is making a mess with the parameters and the outcome is not what you think. Let’s make a simple application example:

macro macroTest(var1,var2) {
      NoOp(Var 1 is ${var1});
      NoOp(Var 2 is ${var2});
}


context astsms {
        _[0-9]. => {
                NoOp(${MESSAGE(body)});
                &macroTest(${MESSAGE(body)},TEST);
                Hangup();
        }
}

If you send a simple message like “Get this one (”, the parameters passed to the macro are messed up and the decoding in the macro fails.

-- Executing [104@astsms:1] NoOp("Message/ast_msg_queue", "Get this one (") in new stack
-- Executing [104@astsms:2] Gosub("Message/ast_msg_queue", "macroTest,~~s~~,1(Get this one (,TEST)") in new stack
-- Executing [~~s~~@macroTest:1] MSet("Message/ast_msg_queue", "LOCAL(var1)=Get this one (,TEST") in new stack
-- Executing [~~s~~@macroTest:2] MSet("Message/ast_msg_queue", "LOCAL(var2)=") in new stack
-- Executing [~~s~~@macroTest:3] NoOp("Message/ast_msg_queue", "Var 1 is Get this one (,TEST") in new stack
-- Executing [~~s~~@macroTest:4] NoOp("Message/ast_msg_queue", "Var 2 is ") in new stack
-- Executing [~~s~~@macroTest:5] Return("Message/ast_msg_queue", "") in new stack
-- Executing [104@astsms:3] Hangup("Message/ast_msg_queue", "") in new stack

How can this be solved? How to make the parameters be correctly managed by the macro?

Thank you


#2

Very few people here use AEL, and, as I understand it, AEL actually implements Macro with subroutines, so it is possible that this is an AEL specific problem.