GLBasic User Manual

Main sections

GETENV$()

value$ = GETENV$( name$ )



Returns the value of an environment variable. If the variable is not set, an empty string will be returned.

You can set the environment variables in a command window with the SET command or in the operating system preferences. In Windows batch files you access them with %NAME%. Environment variables are process specific. If you spawn a new process with SHELLCMD it will inherit the variables from the parent process.

If name$ is empty, a list of all available variables is returned, separated by "\n".

// Console Program
STDOUT GETENV$("") // list all variables

path$ = GETENV$("PATH")
PUTENV "PATH", path$+";C:/Test/myprogram"

STDOUT "\n\nPATH: " + GETENV$("PATH") // list path again

KEYWAIT

See also...