Search:
     
3CX Phone System for Windows Download the Free Edition

Asterisk cmd Math

Math

cmd Math is deprecated in Asterisk 1.2. use func Math instead

Synopsis

 math(returnvar,operation,number)


Description

Adds Sum, Multiply, Divide, Subtract, Modulus, GT, LT, GTE, LTE, EQ functions

All functions follow the same basic pattern for parameters:

  • returnvar: the name of the return variable
  • operation: the operation
  • number: the second number

Each action is performed as
 Action param1 on param2

eg:
Action = Divide
Param1 = 10
Param2 = 2

Results in
Divide 10 by 2

Example

Example dialplan:

exten => 11099,1,Math(RV,1+20)
exten => 11099,2,NOOP(${RV})
exten => 11099,3,Math(RV,10*2)
exten => 11099,4,NOOP(${RV})
exten => 11099,5,Math(RV,10*2)
exten => 11099,6,NOOP(${RV})
exten => 11099,7,Math(RV,10-2)
exten => 11099,8,NOOP(${RV})
exten => 11099,9,Math(RV,2%10)
exten => 11099,10,NOOP(${RV})
exten => 11099,11,Math(RV,10/0)
exten => 11099,12,NOOP(${RV})
exten => 11099,13,math(RV,10-200)
exten => 11099,14,NOOP(${RV})
exten => 11099,15,Math(RV,1-20)
exten => 11099,16,NOOP(${RV})
exten => 11099,17,Math(RV,1<20)
exten => 11099,18,NOOP(${RV})
exten => 11099,19,Math(RV,1>=20)
exten => 11099,20,NOOP(${RV})
exten => 11099,21,Math(RV,101>20)
exten => 11099,22,NOOP(${RV})
exten => 11099,23,Math(RV,1==20)
exten => 11099,24,NOOP(${RV})
exten => 11099,25,Math(RV,20<=20)
exten => 11099,26,NOOP(${RV})

Version info

  • The MATH application was added to CVS head october 2004, after 1.0.2 release (at least my 1.0.2 does not contain it :-).

See also:



Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ

Created by: JustRumours,Last modification on Fri 12 of Oct, 2007 [12:18 UTC] by chandave


Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

 





Search: