18.01.2013 Views

LotusScript for Visual Basic Programmers - IBM Redbooks

LotusScript for Visual Basic Programmers - IBM Redbooks

LotusScript for Visual Basic Programmers - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Accessing Notes Session Environment Values<br />

Using GetEnvironmentString, SetEnvironmentVar and<br />

GetEnvironmentValue, we can access Notes session environment values.<br />

The GetEnvironmentValue, GetEnvironmentString, and SetEnvironmentVar<br />

methods retrieve and set environment variables, which are stored in the<br />

local NOTES.INI or Preferences file. Use GetEnvironmentValue only <strong>for</strong><br />

numeric environment variables. Use GetEnvironmentString <strong>for</strong> strings and<br />

numeric values.<br />

SetEnvironmentVar prepends a dollar sign ($) to argument 1, the name of<br />

the environment variable. This <strong>for</strong>ces a distinction between user<br />

environment variables (name starts with a dollar sign) and system<br />

environment variables (name does not start with a dollar sign).<br />

GetEnvironmentValue and GetEnvironmentString prepend a dollar sign if<br />

the second argument is false or omitted, and do not prepend a dollar sign if<br />

the second argument is true. This permits you to examine system<br />

environment variables as well as user ones.<br />

Environment variables are useful <strong>for</strong> saving state and data between Notes<br />

sessions on a single server or workstations where no conflicts are possible.<br />

They are also useful <strong>for</strong> obtaining the environment in<strong>for</strong>mation set by<br />

Notes, such as KitType, Directory, Preferences, Domain, Port, and so on.<br />

Let’s look at an example.<br />

Example<br />

The following example shows how to set a Notes environment value in<br />

NOTES.INI.<br />

Dim session As Object<br />

Set session = CreateObject("notes.notessession")<br />

Call session.SetEnvironmentVar("TestOfAPI", "IT WORKS")<br />

Set session = Nothing<br />

Following is an explanation of the code.<br />

We use the SetEnvironmentVar method of SessionObject to set the<br />

environment variable.<br />

Call session.SetEnvironmentVar("TestOfAPI", "IT WORKS")<br />

Chapter 6: Accessing Notes Sessions 119

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!