Click or drag to resize

SetEnv Function (String, String)

X#
Update or replace the contents of a DOS environment variable.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax
 FUNCTION SetEnv(
	cVar AS STRING,
	cValue AS STRING
) AS LOGIC
Request Example View Source

Parameters

cVar
Type: String
The environment variable to be modified.
cValue
Type: String
The new value to assign to the environment variable.

Return Value

Type: Logic
TRUE if successful; otherwise FALSE.
Remarks
SetEnv() lets you either append or replace a DOS environment variable from within an application. Typically this is configuration information-- including path names--that describes the location of files (database, index, label, or reports). Note: Instead of using environment variables for configuring your application, you may want to consider using registry settings.
Examples
These examples modify the DOS PATH:
X#
1? SetEnv("PATH","D:\CAVO2x\BIN", .F.)  //Overwrites PATH
2? GetEnv("PATH")
3? SetEnv("PATH", "C:\MyApp", .T.)  //Appends to the end of PATH
4? GetEnv("PATH")
See Also