Click or drag to resize

SetEnv Function (String, String, Logic)

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,
	lAppend AS LOGIC
) 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.
lAppend
Type: Logic
Logical value indicating whether the new value should be appended to the old value (TRUE) or if it should replace the old value (FALSE).

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