SetUserEnv(environment_variable,value )
Where:
environment_variable | is a user environment variable name. The environment_variable may not contain embedded spaces. If the environment_variable does not already exist, it is created. |
value | the value assigned to environment_variable. |
environment_variable and value may be TN3270 Plus variables.
The SetUserEnv command sets the value of a user environmental variable. This user environment variable is then accessible by external programs like PowerShell or VBScript. This makes it easy to pass information from a TN3270 Plus script to an external program. The user environment variables are visible in the "HKEY_CURRENT_USER\Environment" registry key.
Examples
SetUserEnv(ProductNumber,3270)
SetUserEnv(Description,"Terminal Emulator")
MsgBox(%ProductNumber%)
Sample Scripts
The following TN3270 Plus sample script assigns a value to a user environment variable.
' SetUserEnvironmentVariable.txt
' Example that sets a user environment variable
SetUserEnv(ProductNumber,3270)
exit
The following VBscript accesses the user environment variable created in the TN3270 Plus script above.
'DisplayUserEnvironmentVariable.vbs
' Windows VBScript to display a user environment variable
Dim objWSH
Dim objUserVariables
Set objWSH = CreateObject( "WScript.Shell" )
Set objUserVariables = objWSH.Environment("USER")
MsgBox(objUserVariables("ProductNumber"))
The following PowerShell script accesses the user environment variable created in the TN3270 Plus script above.
# DisplayUserEnvironmentVariable.ps1
# Windows PowerShell script to display a user environment variable
[environment]::GetEnvironmentVariable("ProductNumber", "User")
See Also:
TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.