cond, C-like "expr ? truevalue : falsevalue"

The "cond" construct will be substituted by its truevalue if expr is evaluated to true, or by its falsevalue in the other case.

The general format of the cond function is (note the spaces around question mark and around colon):

${cond(<expr> ? <truevalue> : <falsevalue>)}  

Let's see an example extension using "cond" construct:

<extension name="COND"> 
      <condition field="destination_number" expression="^2914$">   
        <action application="log" data="ERR ${cond(${username} == 1011 ? YESSSS : NOOOOT)}"/> 
      </condition> 
</extension> 

Calling 2914 from a phone registered as user 1011 will output:

Comparison operators are:

  • == equality
  • != not equal
  • > greater than
  • >= greater than or equal to
  • < less than
  • <= less than or equal to

You can compare strings with strings and numbers with numbers, but if you compare a string to a number, they will be compared as strlen(string) and the number.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.137.240