Import
Raffriff42 (Talk | contribs) m (formatting) |
|||
Line 1: | Line 1: | ||
+ | <div style="max-width:62em" > | ||
{{Template:FuncDef|Import(string filename [, ... ])}} | {{Template:FuncDef|Import(string filename [, ... ])}} | ||
− | + | Evaluates the contents of other AviSynth scripts at the point of invocation. | |
− | [[Script_functions|Functions]], [[Script_variables|variables]] and loaded plugins declared inside the imported script are made available to the importing script. In addition, the return value of the function is the last value of the last | + | [[Script_functions|Functions]], [[Script_variables|variables]] and loaded plugins declared inside the imported script are made available to the importing script. In addition, the return value of the function is the last value of the last {{FuncArg|filename}} script (a clip or whatever the script chooses to end with). The latter can be assigned to a variable of the importing script and manipulated (this is most useful when the imported script ends with a clip). |
The current working directory (CWD) is saved and set to the directory containing the script file before compiling the script. The CWD is then restored to the saved directory. | The current working directory (CWD) is saved and set to the directory containing the script file before compiling the script. The CWD is then restored to the saved directory. | ||
− | Some indicative uses of Import include: | + | Some indicative uses of '''Import''' include: |
* Storing multiple script-functions, variables and global variables for reuse by scripts (creation of script libraries). | * Storing multiple script-functions, variables and global variables for reuse by scripts (creation of script libraries). | ||
* Retrieving pre-built streams. | * Retrieving pre-built streams. | ||
* Retrieving dynamically configured pre-built streams (the core idea is that the importing script declares some global variables which the imported script uses to configure the stream that will return). | * Retrieving dynamically configured pre-built streams (the core idea is that the importing script declares some global variables which the imported script uses to configure the stream that will return). | ||
+ | </div> | ||
---- | ---- | ||
− | '''Note 1''': Since the contents of the imported script are evaluated at the point of invocation, it is possible by enclosing the Import | + | <div style="max-width:62em" > |
+ | '''Note 1''': Since the contents of the imported script are evaluated at the point of invocation, it is possible by enclosing the '''Import''' call in a nested scope (for example inside a function) to make available to the importing script the functions and globals of the imported script ''without'' its script-level variables. | ||
'''Note 2''': Any script with the [[AVSI]] extension in the AviSynth Plugins folder is automatically imported. This is useful for making script functions available to any new script you create without having to copy and paste. | '''Note 2''': Any script with the [[AVSI]] extension in the AviSynth Plugins folder is automatically imported. This is useful for making script functions available to any new script you create without having to copy and paste. | ||
+ | </div> | ||
[[Category:Internal filters]] | [[Category:Internal filters]] | ||
[[Category:Media file filters]] | [[Category:Media file filters]] |
Revision as of 09:40, 28 February 2016
Import(string filename [, ... ])
Evaluates the contents of other AviSynth scripts at the point of invocation.
Functions, variables and loaded plugins declared inside the imported script are made available to the importing script. In addition, the return value of the function is the last value of the last filename script (a clip or whatever the script chooses to end with). The latter can be assigned to a variable of the importing script and manipulated (this is most useful when the imported script ends with a clip).
The current working directory (CWD) is saved and set to the directory containing the script file before compiling the script. The CWD is then restored to the saved directory.
Some indicative uses of Import include:
- Storing multiple script-functions, variables and global variables for reuse by scripts (creation of script libraries).
- Retrieving pre-built streams.
- Retrieving dynamically configured pre-built streams (the core idea is that the importing script declares some global variables which the imported script uses to configure the stream that will return).
Note 1: Since the contents of the imported script are evaluated at the point of invocation, it is possible by enclosing the Import call in a nested scope (for example inside a function) to make available to the importing script the functions and globals of the imported script without its script-level variables.
Note 2: Any script with the AVSI extension in the AviSynth Plugins folder is automatically imported. This is useful for making script functions available to any new script you create without having to copy and paste.