Documentation |
Documentation.Script-Operators HistoryHide minor edits - Show changes to markup July 21, 2015, at 11:43 AM
by
- Changed lines 1-73 from:
Documentation -> Manuals -> Manual devel -> Script Operators(:title Script Operators - ver devel :) Page for other versions: devel 1.9 1.8 old versions: 1.7 1.6 1.5 1.4
(:toc-float Table of Content:) Assignments, string and arithmetic operations can be done directly in the configuration file. AssignmentAssignments 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 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 operationsFor strings, '+' is available to concatenate. $var(a) = "test"; $var(b) = "sip:" + $var(a) + "@" + $fd; Arithmetic and bitwise operationsFor numbers, one can use:
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"); to:
(:redirect Documentation.Script-Operators-2-2 quiet=1:) May 29, 2013, at 12:53 AM
by
- Changed line 21 from:
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 listing of variables to see which ones can be written too. to:
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 listing of variables to see which ones can be written too. May 29, 2013, at 12:43 AM
by
- Deleted line 12:
May 29, 2013, at 12:43 AM
by
- Changed lines 1-2 from:
Documentation -> Manuals -> Manual 1.9 -> Script Operatorsto:
May 27, 2013, at 08:22 PM
by
- Deleted lines 5-7:
Script OperationsMay 27, 2013, at 08:22 PM
by
- Added lines 1-67:
Documentation -> Manuals -> Manual 1.9 -> Script Operators(:toc-float Table of Content:) Script OperationsAssignments, string and arithmetic operations can be done directly in the configuration file. AssignmentAssignments 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 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 operationsFor strings, '+' is available to concatenate. $var(a) = "test"; $var(b) = "sip:" + $var(a) + "@" + $fd; Arithmetic and bitwise operationsFor numbers, one can use:
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"); |