GUI with Global Variables

Be careful when using GUI specifiers with global variables, because Silk Test Classic initializes global variables before connecting to an Agent. This might not give you the results you want if you are doing distributed testing.

Let’s say that you are running tests on a remote machine that is listed in the Runtime Options dialog box. Because Silk Test Classic initializes all global variables before connecting to an Agent, any GUI specifier at the global level will initialize to the host machine, not the target machine you want to test against.

For example, say the host machine is running a different operating system than the target machine. Consider the following script:

mswxp STRING sVar1 = SYS_GetEnv("UserName")

mswxp STRING sVar1 = SYS_GetRegistryValue 
   (HKEY_LOCAL_MACHINE,     "System\CurrentControlSet\Control", "Current User")


This script fails, with the error message:

*** Error: Registry entry 'Current User' not found

because sVar1 is initialized to the value for the host system, not the target system.

Constants behave similarly to global variables if you use a GUI specifier to initialize the variable (or constant). It is a good idea to use GUI specifiers in the main function, under Options > Runtime or another function that is called after the Agent is contacted.