Examples: Using environment variables
- This button example increments the environment variable $SeqNo
by one and prints the result. (This script would not be reliable on
a server for maintaining a system of sequential numbers.)
Sub Click(Source As Button) Dim session As New NotesSession seqNo = session.GetEnvironmentValue("SeqNo") If Isempty(seqNo) Then Call session.SetEnvironmentVar("SeqNo", 1) Else seqNo = seqNo + 1 Call session.SetEnvironmentVar _ ("SeqNo", Cint(seqNo)) End If Messagebox session.GetEnvironmentValue("SeqNo") End Sub
- This agent example prints the value of a system environment variable.
GetEnvironmentString is used to accept an environment variable that
is either a number or a string. The second argument to GetEnvironmentString
is true so that a dollar sign is not prepended to the name of the
environment variable.
Sub Initialize Dim session As New NotesSession envVarName = Inputbox$("Environment variable name") envVar = session.GetEnvironmentString(envVarName, _ True) If envVar = "" Then Messagebox(envVarName & " not set") Else Messagebox(envVarName & " = " & envVar) End If End Sub