Log in

View Full Version : Using environment variables in scripts - is it possible?


kypec
19th June 2009, 06:08
I'm trying to make use of system variables for portability of my scripts across more OS but the following syntax doesn't work for me:LoadCPlugin("%PROGRAMFILES%\AVTools\Plugins\yadif.dll")
Is there any way to tell Avisynth to use these path notations instead of hardcoded paths within filename strings?:stupid:
Please note that this is a 'C' plugin and as such is not recommended to be put in common plugins autoload directory.

vampiredom
19th June 2009, 08:01
Take a look at the GetSystemEnv plugin. You can use this to load environment variables…

… or, in my case:

I use GetSystemEnv to find the AviSynth plugins folder by creating a file called AviSynthPluginsDir.avsi, which is auto-loaded. The file contains:

global AviSynthPluginsDir = GetWorkingDir()

When this .avsi is autoloaded, it will assign a global variable called AviSynthPluginsDir that can be accessed by other scripts.

So, for C:\Program Files\AviSynth 2.5\plugins\yadif\yadif.dll you can use:

LoadCPlugin(AviSynthPluginsDir + "yadif\yadif.dll")

RedDwarf1
13th April 2010, 23:05
This seemed like it could be useful to me as I have multiple windows installs and need to use scripts in each of them so they need to be portable between different windows.

But it is not full working. I am getting an error every time AvsP starts.

Error parsing GetSystemEnv_GetSystemEnv plugin parameters: unknown character

Other than the error it works but it's a bit annoying having to close an error window every time I start AvsP. Is there a reason for this error message?

lol I typed it out rather than copying it and now it works without errors. The text looked identical but couldn't of been.

So if you copy it, you could get an error!

Vitaliy Gorbatenko
14th April 2010, 11:19
Much easy!!!:

SetWorkingDir("C:\system\Knot\AviSynthPlugins\")
import("Killer.avsi")
import("MVDegrain2i.avsi")
LoadPlugin("bifrost.dll")
[...]

Not more full path!!

stickboy
14th April 2010, 11:32
lol I typed it out rather than copying it and now it works without errors. The text looked identical but couldn't of been.

So if you copy it, you could get an error!I don't understand. Type what out? Copy what?

RedDwarf1
14th April 2010, 15:08
Much easy!!!:

SetWorkingDir("C:\system\Knot\AviSynthPlugins\")
import("Killer.avsi")
import("MVDegrain2i.avsi")
LoadPlugin("bifrost.dll")
[...]

Not more full path!!

I wanted to keep the AVISynth installs separate incase anything conflicts. Done your way would mess up other parts of my script, requiring full paths to reference files. vampiredom's way works nicely.

I don't understand. Type what out? Copy what?

Copying the text posted by vampiredom:
global AviSynthPluginsDir = GetWorkingDir()
and pasting into Notepad (++) and it must of copied some extra character(s) from this forum which made AvsP/AVISynth object to a special character which got copied which produced the error window.

Typing it out into Notepad and saving worked correctly.

[EDIT]
But whatever happened I cannot reproduce it now. The original file still causes the problem and looks identical to the working one. The format is identical Dos/Windows ANSI :confused:

Gavino
17th April 2010, 01:07
I am getting an error every time AvsP starts.
Error parsing GetSystemEnv_GetSystemEnv plugin parameters: unknown character
lol I typed it out rather than copying it and now it works without errors. The text looked identical but couldn't of been.
I have discovered this is due to a bug in Avisynth's mechanism for communicating plugin parameters to applications, and can occur if a function from an auto-loaded plugin is called from an auto-loaded .avsi file. See here.

Because it involves memory corruption, the problem does not always show up, which explains why your two tests behaved differently.