GetEnvironment

<< Click to Display Table of Contents >>

Navigation:  Reference (Scripting) > Docklight Script Commands - The DL Object > Methods (Advanced) >

GetEnvironment

Returns the value of a Windows environment variable in the currently active user profile, or a value of one of the Docklight-specific environment variables described below.

 

Return Value

 

String

 

Syntax

 

result = DL.GetEnvironment( name )

 

The GetEnvironment method syntax has these parts:

 

Part

Description

name

Required.

name can be:

1) The name of the Windows environment variable. (Not including the %-signs around it that are used in the Windows Command Shell cmd.exe).

 

2) One of the Docklight-specific names listed below

 

Docklight Scripting Environment Variables

 

Name

Description

DOCKLIGHT_VERSION

Docklight Scripting application version

DOCKLIGHT_SCRIPTDIR  

the folder the script runs in

DOCKLIGHT_DIALOGDIR

the folder used for the last script file dialog used

DOCKLIGHT_PORTLIST

list of COM ports available on this PC

DOCKLIGHT_SENDSEQ

list of all Send Sequence names in the current Docklight project (.ptp file)

DOCKLIGHT_RECEIVESEQ

list of all Receive Sequence names

DOCKLIGHT_SENDSEQDEF

list of all Send Sequences Name and Sequence in HEX format. Name and Sequence are returned in separated text lines

DOCKLIGHT_SENDSEQDEF:

SequenceName

Lists the definition only for the sequence names that match SequenceName.  

 

SequenceName can contain wildcards, e.g. you can use:
DOCKLIGHT_SENDSEQDEF:Test*

DOCKLIGHT_RECEIVESEQDEF

same as DOCKLIGHT_SENDSEQDEF but for Receive Sequences

 

Remarks

 

The list of environment variables used in the example below is just an example.

 

For details and available variables on other versions of Windows, please refer to the other resources, e.g. the "Windows XP Command shell overview" at www.microsoft.com  . For a list of variables available on your current user profile, open a Windows Command Processor window (cmd.exe), then type SET and press Enter.

 

NOTE: In Docklight Scripting V2.0 and earlier this method was called GetEnvironmentVariable. The old name is still supported for compatibility reasons. It was changed to avoid confusion with the Windows API function of the same name.

 

Example

 

' Example GetEnvironment

 

nameList = "ALLUSERSPROFILE,APPDATA,COMPUTERNAME,HOMEDRIVE,HOMEPATH,LOCALAPPDATA,LOGONSERVER,NUMBER_OF_PROCESSORS,OS,PROCESSOR_ARCHITECTURE,PROCESSOR_IDENTIFIER,PROCESSOR_LEVEL,PROCESSOR_REVISION,PUBLIC,TEMP,TMP,USERDOMAIN,USERNAME,USERPROFILE"

 

DL.AddComment "Running Docklight Scripting " & DL.GetEnvironment("DOCKLIGHT_VERSION")

nameArray = Split(nameList , ",")

For i = 0 To UBound(nameArray)

  name = nameArray(i)

  DL.AddComment name & " = " & DL.GetEnvironment(name)

Next

 

On a Windows 7 x64 PC, the communications window output could look like this:

 

Running Docklight Scripting Version 2.1.4

ALLUSERSPROFILE = C:\ProgramData

APPDATA = C:\Users\docklight\AppData\Roaming

COMPUTERNAME = FUHEDV5

HOMEDRIVE = C:

HOMEPATH = \Users\docklight

LOCALAPPDATA = C:\Users\docklight\AppData\Local

LOGONSERVER = \\FUHEDV5

NUMBER_OF_PROCESSORS = 4

OS = Windows_NT

PROCESSOR_ARCHITECTURE = x86

PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 37 Stepping 5, GenuineIntel

PROCESSOR_LEVEL = 6

PROCESSOR_REVISION = 2505

PUBLIC = C:\Users\Public

TEMP = C:\Users\docklight\AppData\Local\Temp

TMP = C:\Users\docklight\AppData\Local\Temp

USERDOMAIN = FUHEDV5

USERNAME = docklight

USERPROFILE = C:\Users\docklight