system.setenv
Sets the environment variable to the given value
Parameters
name | string | name of the environment variable to set |
value | string | value to give it |
Errors
Throws setenv() failed if the underlying call fails (_putenv_s on Windows, setenv elsewhere on PC).
Notes
This function only exists in this form on a PC target. sqstdsystem.cpp builds it, getenv and system only #if _TARGET_PC; every other target (consoles, mobile) gets a stub instead, whose docstring reads "Stub: setenv() is not available on this platform". That stub throws setenv() not available for this platform, so code meant for those targets should treat this function as absent and catch the error, or avoid it.
No example runs here because setting an environment variable changes the process, which every example on this site must avoid. Typical use:
from "system" import setenv, getenv
setenv("MY_VAR", "1")
assert(getenv("MY_VAR") == "1")
See also
getenv | Returns the value of the environment variable or null |
| system | module index |