This page shows how to use variables to store intermediate values for further processing in a script. It also describes the types of data that scripts can manipulate, and how literals (constants) of those types are written.
A variable name can be a character string of practically any length (more than 4000 characters in Avisynth 2.56 and later) that contains (English) letters, digits, and underscores (_), but no other characters. The name cannot start with a digit.
You may use characters from your language system codepage (locale) in strings and file names (ANSI 8 bit only, not Unicode).
A variable's placement in an expression is determined by the
Variables can have a value of one of the following types:
Subtitle("""AVISynth is as they say "l33t".""")
There is another type which is used internally by Avisynth - the void or 'undefined' type. Its principal use is in conjunction with optional function arguments. See the Defined() function.
Variables can be either local (bound to the local scope of the executing script block) or global. Global variables are bound to the global script environment's scope and can be accessed by all Internal functions, User defined script functions, runtime environment scripts and the main script also.
To define and / or assign a value to a global variable you must precede its name with the keyword global at the left side of the assignment. The keyword is not needed (actually it is not allowed) in order to read the value of a global variable. Examples:
global canvas = BlankClip(length=200, pixel_type="yv12") global stroke_intensity = 0.7 ... global canvas = Overlay(canvas, pen, opacity=stroke_intensity, mask=brush)
To declare a variable, simply type the variable name, followed by '=' (an equals sign), followed by its initial value. The type must not be declared; it is inferred by the value assigned to it (and can actually be changed by subsequent assignments). The only place where it is allowed (though not strictly required) to declare a variable's type is in user defined script function's argument lists. Examples:
b = false # this declares a variable named 'b' of type 'bool' and initializes it to 'false' x = $100 # type int (initial value is in hexadecimal) y = 256 # type int (initial value is in decimal) global f = 0.0 # type float declared globally ... function my_recolor_filter(clip c, int new_color, float amount, val "userdata") { ... }
$Date: 2008/12/21 09:23:02 $