AviSynth Syntax - Operators

As in all programming and scripting languages, operators in AviSynth script language allow the performance of actions (operations) onto variables. Operators form the basis for building up expressions, the building blocks of AviSynth scripts.

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 at the text below.

Available Operators per Type

For all types of operands (clip, int, float, string, bool) you can use the following operators:

== is equal
 != not equal
<> not equal (alternative to !=, v2.07)

For numeric types (int, float) you can use the following int/float-specific operators:

+ add
- subtract
* multiply
/ divide
% mod
>= greater or equal than
<= less or equal than
< less than
> greater than

AviSynth in former versions parsed expressions from right to left, which gave unexpected results. For example:

These "bugs" have been corrected in v2.53!

For string type you can use the following string-specific operators:

+ concatenate
>= greater or equal than (v2.07)
<= less or equal than (v2.07)
< less than (v2.07)
> greater than (v2.07)

For clip type you can use the following clip-specific operators:

+ the same as the function UnalignedSplice
++ the same as the function AlignedSplice

For bool type (true/false) you can use the following bool-specific operators:

|| or
&& and
 ?: execute code conditionally

The conditional execution operator is used as in the following example:

b = (a==true) ? 1 : 2

This means in pseudo-basic:

if (a=true) then b=1 else b=2

From version v2.07, AviSynth provides a NOP() function which can be used inside a conditional execution block in cases where "else" may not otherwise be desirable (such as a conditional Import or LoadPlugin).

Operator Precedence

The precedence of AviSynth operators is presented at the table below. Operators higher to the top of the table have higher precedence. Operators inside the same row have the same order of precedence.

* / %  
+ ++ -  
< > <= >=  != <> ==
&&  
||  
 ?:  

$Date: 2008/04/21 20:31:23 $