Environment Functions
Contents
cla140
Contents
The Environment functions can be used on Windows NT/9x and UNIX platforms.
EnvExport - Export the Environment to a Text File
Valid on UNIX and Windows
The EnvExport function exports the current environment to a text file.
Function format:
EnvExport(filename as String) as Boolean
- filenameThis parameter defines the name of the text file.
On successful completion, the function returns TRUE; otherwise, it returns FALSE.
Example:
Rem Rem Exports defined environment variables Rem EnvExport("c:\temp\env.dat")
EnvGetFirst - Retrieve the Name of the First Environment Variable
Valid on UNIX and Windows
The EnvGetFirst function retrieves the first environment variable name.
Function format:
EnvGetFirst() as string
Defines a string containing the name of the first environment variable returned. If no more environment variables exist, an empty string is returned.
Example:
This example displays all the environment variable names.
Dim txt as String txt = EnvGetFirst() While txt <> "" Print(txt) txt = EnvGetNext() Wend
EnvGetNext - Retrieve the Name of the Subsequent Environment Variables
Valid on UNIX and Windows
The EnvGetNext function continues the EnvGetFirst function, retrieving the name of subsequent environment variables. For each call of EnvGetNext, one environment variable name is returned until no more environment variables are found.
Function format:
EnvGetNext() as string
The return value is a string containing the name of an environment variable. If no more environment variables exist, an empty string is returned.
Example:
This example displays all the environment variable names.
Dim txt as String txt = EnvGetFirst() While txt <> "" Print(txt) txt = EnvGetNext() Wend
EnvGetString - Retrieve the Value of an Environment Variable
Valid on UNIX and Windows
The EnvGetString function retrieves the value of an environment variable.
Function format:
EnvGetString(name as string) as string
- nameThis parameter defines the name of the environment variable.
The function returns a string containing the value that is associated with name. If an environment variable specified by name does not exist, the function returns an empty string.
Example:
This example displays the current search path.
Rem variable `MyPath´ Rem Dim txt as String txt = EnvGetString("PATH") Print("The path: "+txt) EnvSetString("MyPath",txt) Print("My path: "+txt)
EnvImport - Import Environment Variables
Valid on UNIX and Windows
The EnvImport function imports environment variables from a text file.
Function format:
EnvImport(filename as String) as Boolean
- filenameThis parameter defines the name of the file.
On successful completion, the function returns TRUE; otherwise, returns FALSE.
Example:
This example imports extra env variables from a file.
EnvImport("c:\temp\env.dat")
C:\temp\env.dat contains for example:
Xantippe=greek Yokohama=japanese Fuel=explosive