[Home]

Summary:ASTERISK-00398: Gotoif condition is not as expected
Reporter:florian (florian)Labels:
Date Opened:2003-10-18 14:41:59Date Closed:2004-09-25 02:24:30
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/Configuration
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:From README.variables we learn:
"condition" is just a string. If the string is empty or "0", the condition
is considered to be false, if it's anything else, the condition is true.

However, this does not hold true. In the scenario below the variable FROMPROMPT may be undefined (empty)
exten = s,7,Gotoif(${FROMPROMPT}?s|8:s|9)

When executing, this gives:
   -- Executing GotoIf("MGCP/aaln/1@172.28.4.51-1", "?s|9:s|8") in new stack
   -- Goto (personal-demo,s,9)

   -- Executing GotoIf("IAX2[iaxtel@12.37.165.130:4569]/5", "from-iaxtel?s|9:s|8") in new stack
   -- Goto (personal-demo,s,9)

As you can see if the evaluation is emtpy, Gotoif makes a wrong decision.



****** ADDITIONAL INFORMATION ******

A very simple workaround is to simply append a '0' to the evaluation:

exten = s,7,Gotoif(${FROMPROMPT}0?s|8:s|9)

Now the evaluation will never be empty, but it may be '0' which evaluates to false.
Comments:By: Tilghman Lesher (tilghman) 2003-10-21 23:20:31

Why not instead of evaluating the variable directly, you use an explicit condition?

exten => s,7,GotoIf($[${FROMPROMPT} != ""]?s|8:s|9)

By: florian (florian) 2003-10-22 02:27:36

well, technically that is just another 'workaround'.

I think either the documentation (README.variables) should be modified or the empty string should evaluate 'false'..

Thanks for the suggestion nontheless :-)

edited on: 10-22-03 02:25

By: x martinp (martinp) 2003-11-03 17:40:16.000-0600

well the readme also says to use $[ something ] to evaluate any expression

simply use this

exten => s,7,GotoIf($[${FORMAT}]?s|8:s|9)