From dbddd24443348c19c79e9d85f40d2aa429d0d885 Mon Sep 17 00:00:00 2001 From: russell Date: Fri, 16 Mar 2007 01:41:00 +0000 Subject: Making these documentation changes in the 1.4 branch upset various people, so these chanes will only be done in the trunk. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@58955 f38db490-d61c-443f-a65b-d21fe96a405b --- doc/math.txt | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 doc/math.txt (limited to 'doc/math.txt') diff --git a/doc/math.txt b/doc/math.txt new file mode 100644 index 000000000..7718f9e44 --- /dev/null +++ b/doc/math.txt @@ -0,0 +1,69 @@ + +Mathematical dialplan function + +Yeah, I thought it was a little insane too.. + +adds: + +Sum, Multiply, Divide, Subtract, Modulus, GT, LT, GTE, LTE, EQ functions to Asterisk + +All functions follow the same basic pattern for parameters: + +parameter 1 = the math expression +parameter 2 = the type of result + +Perform calculation on number 1 to number 2. Valid ops are: + +,-,/,*,%,<,>,>=,<=,== +and behave as their C equivalents. + + - wanted type of result: + f, float - float(default) + i, int - integer, + h, hex - hex, + c, char - char + +Each math expression is performed as + + Action param1 on param2 + +eg: + + Action = Divide + Param1 = 10 + Param2 = 2 + +Results in + + Divide 10 by 2 + + +Example dialplan: + +exten => 11099,1,Set(RV=${MATH(1+20)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(10*2)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(10*2)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(10-2)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(2%10)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(10/0)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(10-200)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(1-20)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(1<20)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(1>=20)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(101>20)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(1==20)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(20<=20)}) +exten => 11099,n,NOOP(${RV}) +exten => 11099,n,Set(RV=${MATH(123%16,int)}) +exten => 11099,n,NOOP(${RV}) -- cgit v1.2.3