Documentation

Documentation.Script-Operators-1-11 History

Hide minor edits - Show changes to output

March 20, 2014, at 08:28 PM by razvancrainea -
Changed lines 1-2 from:
!!!!!Documentation -> [[Documentation.Manuals|Manuals]] -> [[Documentation.Manual-1-11|Manual devel]] -> Script Operators
(:title Script Operators - devel :)
to:
!!!!!Documentation -> [[Documentation.Manuals|Manuals]] -> [[Documentation.Manual-1-11|Manual 1.11]] -> Script Operators
(:title Script Operators - 1.11 :)
Changed line 8 from:
|| %color=#185662%[+'''Script Operators devel'''+]%% ||
to:
|| %color=#185662%[+'''Script Operators v1.11'''+]%% ||
August 05, 2013, at 03:33 PM by razvancrainea -
Changed lines 1-2 from:
!!!!!Documentation -> [[Documentation.Manuals|Manuals]] -> [[Documentation.Manual-1-11|Manual 1.11]] -> Script Operators
(:title Script Operators - ver 1.11 :)
to:
!!!!!Documentation -> [[Documentation.Manuals|Manuals]] -> [[Documentation.Manual-1-11|Manual devel]] -> Script Operators
(:title Script Operators - devel :)
Changed line 8 from:
|| %color=#185662%[+'''Script Operators v1.11'''+]%% ||
to:
|| %color=#185662%[+'''Script Operators devel'''+]%% ||
August 05, 2013, at 01:58 PM by razvancrainea -
Added lines 1-73:
!!!!!Documentation -> [[Documentation.Manuals|Manuals]] -> [[Documentation.Manual-1-11|Manual 1.11]] -> Script Operators
(:title Script Operators - ver 1.11 :)
----
(:allVersions Script-Operators 1.11 :)

\\

|| %color=#185662%[+'''Script Operators v1.11'''+]%% ||

||[[Script-Routes-1-11|Prev]] || [[Script-Statements-1-11|Next]]||
----

(:toc-float Table of Content:)


Assignments, string and arithmetic operations can be done directly in the configuration file.


!!!!Assignment

Assignments can be done like in C, via '=' (equal) operator. Not that not all variables (from script) can be written, some are read-only. Check with [[Documentation/Script-CoreVar-1-11|listing of variables]] to see which ones can be written too.

[@
$var(a) = 123;
$ru = "sip:user@domain";
@]

There is a special assign operator ':=' (colon equal) that can be used with AVPs. If the right value is '''null''', all AVPs with that name are deleted. If different, the new value will overwrite any existing values for the AVPs with than name (on other words, delete existing AVPs with same name, add a new one with the right side value).

[@
$avp(val) := 123;
@]

!!!!String operations

For strings, '+' is available to concatenate.

[@
$var(a) = "test";
$var(b) = "sip:" + $var(a) + "@" + $fd;
@]


!!!!Arithmetic and bitwise operations

For numbers, one can use:

* + : plus
* - : minus
* / : divide
* * : multiply
* % : modulo
* | : bitwise OR
* & : bitwise AND
* ^ : bitwise XOR
* ~ : bitwise NOT
* << : bitwise left shift
* >> : bitwise right shift

Example:

[@
$var(a) = 4 + ( 7 & ( ~2 ) );
@]

NOTE: to ensure the priority of operands in expression evaluations do use __parenthesis__.

Arithmetic expressions can be used in condition expressions via test operator ' [ ... ] '.

[@
if( [ $var(a) & 4 ] )
log("var a has third bit set\n");
@]

Page last modified on March 20, 2014, at 08:28 PM