zambelli
7th April 2023, 20:32
I would like to use the Import() function to call a script which returns video as a result. However, I don't want any global variables defined in the child script to be visible to the parent script (or vice versa, though that one is less of a problem).
For example, let's say that there exist 2 scripts - video1.avs and video2.avs - and both define a global variable named x within their respective scopes. Both scripts return video as result.
Let's say my main script imports both scripts and assigns their returned videos to variables:
global x = "foo"
v1 = Import("video1.avs")
v2 = Import("video2.avs")
Interleave(v1, v2).Subtitle(x)
I want the value of x in the Subtitle() function to be "foo" regardless of what value the child scripts assign to x in their own scope.
I tried wrapping Import() in a function thinking that it might restrict the imported script's variables to the scope of the function, but that didn't change the behavior.
function LoadAvsSource(string "srcScriptPath")
{
vid = Import(srcScriptPath)
return vid
}
global x = "foo"
v1 = LoadAvsSource("video1.avs")
v2 = LoadAvsSource("video2.avs")
Interleave(v1, v2).Subtitle(x)
Same result.
Is there a way keep the imported script's scope isolated from the parent script?
For example, let's say that there exist 2 scripts - video1.avs and video2.avs - and both define a global variable named x within their respective scopes. Both scripts return video as result.
Let's say my main script imports both scripts and assigns their returned videos to variables:
global x = "foo"
v1 = Import("video1.avs")
v2 = Import("video2.avs")
Interleave(v1, v2).Subtitle(x)
I want the value of x in the Subtitle() function to be "foo" regardless of what value the child scripts assign to x in their own scope.
I tried wrapping Import() in a function thinking that it might restrict the imported script's variables to the scope of the function, but that didn't change the behavior.
function LoadAvsSource(string "srcScriptPath")
{
vid = Import(srcScriptPath)
return vid
}
global x = "foo"
v1 = LoadAvsSource("video1.avs")
v2 = LoadAvsSource("video2.avs")
Interleave(v1, v2).Subtitle(x)
Same result.
Is there a way keep the imported script's scope isolated from the parent script?