The Env extension: reading environment variables

Download Env extension

For camotit, here's a Vocola 2 extension that provides a single extension function, Env.Get(name[,if_undefined]) for retrieving the values of environment variables. Env.Get(HOME) for example, returns the value of the environment variable HOME if it is defined; otherwise, a run-time error occurs. If you prefer a default value be used if the environment variable is undefined instead of a runtime error, pass the default value as the second argument like so: Env.Get(HOME, "C:\Users\Mark\Documents").

If you want to test the extension, you can use the following Vocola commands:

     environment (home=HOME|unknown) = Env.Get($1);
safe environment (home=HOME|unknown) = Env.Get($1,"UNKNOWN");