Log in

View Full Version : Using variables from outside AVS?


Raga
22nd April 2006, 18:42
Does AVS support functionality for variables coming from outside the script? I could run it from command line with certain parameters at the end, which would then be used by the script?

I looked at the pinned thread with command line utilities, but didn't see this covered.

"Too lazy to open it up in a text editor."

Richard Berg
22nd April 2006, 22:07
It would be easy to write a plugin to get & set environment variables. Would that help?

Raga
22nd April 2006, 22:23
I suppose that would work, too, yes.

Come to look at it a bit more carefully, env variables set with SET (http://www.ss64.com/nt/set.html) are also removed once the command prompt is closed, which is perfect. :)

foxyshadis
22nd April 2006, 23:27
I'm sure it could be very easy. So easy that it's already been done. ;)

GetSystemEnv.dll (http://www.avisynth.org/warpenterprises/files/getsystemenv_25_dll_20050403.zip)
GetSystemEnv("avisynth")

It won't set variables, but it could be modified to fairly trivially, and you don't seem to need that anyway.

Raga
22nd April 2006, 23:42
Testing... It finds the standard env vars just fine, which is a start.

However, it doesn't find the stuff you can set on a per-session basis with SET, even if I execute the AVS script from the same command line I set the variable at. (Testing by writing the variable as a sub on a blank clip.)

foxyshadis
23rd April 2006, 00:28
Odd.


mpeg2source("Funky Cat Maybe.d2v")
subtitle(getsystemenv("new1"))


D:\video>set new1=dude

D:\video>echo %new1%
dude

D:\video>"C:\Program Files\music-video\editing\virtualdub\virtualdub" funky.avs

This produces the video with the subtitle, as expected. Starting from windows explorer gives "variable "new1" not found", as does opening a new command shell and opening the script there.

Richard Berg
23rd April 2006, 06:58
What's odd? Processes inherit their environment from the parent process. Plus whatever's in the System environment (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment). The .Net API makes it really obvious which set of variables you're manipulating.

foxyshadis
23rd April 2006, 07:15
Odd that it didn't work for him, sorry.

Raga
23rd April 2006, 07:49
Bizarre. It started working now... With the exact same setup. Guess it needed to sleep overnight? :confused: