Environ Function

Purpose

Returns and sets the value of an operating system environment variable.

Syntax

Environ[$]("name" | number) [= value$]

Description

Environment variables define the environment in which a process executes (for example, the default search path for libraries to be linked with a program).

If "name" can't be found in the environment-string table, a zero-length string ("") is returned. Otherwise, Environ returns the text assigned to the specified "name"; that is, the text following the equal sign (=) in the environment-string table for that environment variable.

If you specify number, the string occupying that numeric position in the environment-string table is returned. In this case, Environ returns all of the text, including the name. If there is no environment string in the specified position, Environ returns a zero-length string.

Environ("name" | number) = creates new environment variables; modifies or removes existing ones.

Example

Environ("CopyOfPath") = Environ("Path")

Environ("Dircmd") = "/4"

Debug.Show

// path out of the Autoexec.dos

Trace Environ("path")

Trace Environ("comspec")

// more

Trace Environ("TEMP")

Trace Environ("TMP")

Trace Environ(1)

Trace Environ(2)

Trace Environ(14)

Trace Environ(15)

Remarks

See Also

{Created by Sjouke Hamstra; Last updated: 04/10/2014 by James Gaite}