As in all programming and scripting languages, operators in AviSynth script language allow the performance of actions (operations) on variables. Operators form the basis for building expressions, the building blocks of AviSynth grammar.
AviSynth operators follow loosely the same rules as C operators, regarding meaning, precedence and associativity. By 'loosely', we mean that there are some exceptions, indicated below.
Note that as in C, when a binary operator is applied to an int and a float, the int is automatically converted to float prior to the operation.
For All Variable Types
For all types of operands (clip, int, float, string, bool) you can use the following operators:
Operator Meaning == is equal != not equal <> not equal
string comparisons are not case-sensitive, so "abc" == "ABC" returns true.
Note comparisons may be chained:
(3 <= x <= 5)can be used where normally something like
(3 <= x && x <= 5)would be required.(doom9)
For numeric types (int, float) you can use the following numeric-specific operators:
Operator Meaning + add - subtract * multiply / divide % mod >= greater or equal than <= less or equal than < less than > greater than
For string type you can use the following string-specific operators:
Operator Meaning + concatenate >= greater or equal than <= less or equal than < less than > greater than
Like the equality operator, these string comparisons are case-insensitive.
For clip type you can use the following clip-specific operators:
For bool type (true/false) you can use the following bool-specific operators:
Operator Meaning || or && and ?: ternary (conditional execution) operator ! not
The ternary (conditional execution) operator is used as in the following example:
This means, in pseudocode:
The precedence of AviSynth operators is presented at the table below. Operators in the same row have the same precedence.
highest: * / % + ++ - < > <= >= != <> == && || lowest: ?:
The dot [.] symbol ("OOP notation" for a function call, where
a.function(b) is equivalent to
function(a, b)) has a higher precedence than any operator – for example,
is equivalent to
but since parentheses override normal precedence,
is equivalent to
Back to AviSynth Syntax.