|
|
Line 1: |
Line 1: |
− | <div style="max-width:62em" >
| + | #REDIRECT [[Internal_functions#Import]] |
− | {{Template:FuncDef|Import(string filename [, ... ])}}
| + | [[Category:Redirects]] |
− | | + | |
− | 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 {{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.
| + | |
− | | + | |
− | 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).
| + | |
− | </div>
| + | |
− | ----
| + | |
− | <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.
| + | |
− | </div>
| + | |
− | | + | |
| [[Category:Internal filters]] | | [[Category:Internal filters]] |
| [[Category:Media file filters]] | | [[Category:Media file filters]] |