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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

This example sets the value of a Notes environment variable in the<br />

NOTES.INI. If the variable does not already exist, it is created.<br />

Dim hgstatus As Long<br />

hgstatus = HTInit(0)<br />

hgstatus = HTSetEnvironmentString("TestOfAPI", "It worked",<br />

HTSetEnvF_Create)<br />

If hgstatus = 0 Then Print "This environment variable has<br />

been set in your notes.ini file."<br />

hgstatus = HTTerm(0)<br />

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

We set the environment TestOfAPI to “It worked”. If the TestOfAPI does<br />

not already exist in NOTES.INI, we create it. If it fails, an error code is<br />

returned: “Value is longer than the maximum environment string length”.<br />

hgstatus = HTSetEnvironmentString("TestOfAPI", "It worked",<br />

HTSetEnvF_Create)<br />

If the setting is successful, we print out a message to in<strong>for</strong>m the user.<br />

If hgstatus = 0 Then Print "This environment variable has<br />

been set in your notes.ini file."<br />

Accessing Notes Sessions in <strong>Visual</strong> <strong>Basic</strong> Using Notes Classes through<br />

OLE Automation<br />

Using Notes classes through OLE Automation in <strong>Visual</strong> <strong>Basic</strong>, we present<br />

the session as NotesSession. The NotesSession class provides a means <strong>for</strong><br />

accessing attributes of the user environment and in<strong>for</strong>mation about agents.<br />

It also provides methods <strong>for</strong> accessing environment variables.<br />

Following is a table which converts the HiTest <strong>Basic</strong> API functions<br />

accessing Notes sessions to the equivalent functions and properties using<br />

Notes classes through OLE Automation:<br />

116 <strong>LotusScript</strong> <strong>for</strong> <strong>Visual</strong> <strong>Basic</strong> <strong>Programmers</strong>

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

Saved successfully!

Ooh no, something went wrong!