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.

 

TIP: For a list of variables available on your current user profile, open a Windows Command Processor window (Windows Key + R, then type cmd), 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 10 notebook, the communications window output could look like this:

 

Running Docklight Scripting Docklight Scripting V2.4.5

ALLUSERSPROFILE = C:\ProgramData

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

COMPUTERNAME = DOCK-OH

HOMEDRIVE = C:

HOMEPATH = \Users\docklight

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

LOGONSERVER = \\DOCK-OH

NUMBER_OF_PROCESSORS = 4

OS = Windows_NT

PROCESSOR_ARCHITECTURE = x86

PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 78 Stepping 3, GenuineIntel

PROCESSOR_LEVEL = 6

PROCESSOR_REVISION = 4e03

PUBLIC = C:\Users\Public

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

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

USERDOMAIN = DOCK-OH

USERNAME = docklight

USERPROFILE = C:\Users\docklight