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.

Accessing Notes Session Properties<br />

HTGetProperty fetches one of various session-level property values into a<br />

supplied buffer. Each property has a data type, and the buffer must be large<br />

enough to hold the result.<br />

HTSetProperty assigns a value to a session-level property. The type of the<br />

data is indicated by the property. When setting the value of properties<br />

which are inherited by newly opened databases, the new value has no effect<br />

on currently open databases.<br />

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

Example<br />

This example retrieves and prints a session property <strong>for</strong> the current user’s<br />

name.<br />

Dim hgstatus As Long<br />

Dim hgvalue As String<br />

hgvalue = String(HTMaxLen_User_Name, 0)<br />

hgstatus = HTInit(0)<br />

hgstatus = HTGetProperty(HTSession_User_Name, ByVal hgvalue)<br />

hgvalue = Left(hgvalue, InStr(hgvalue, Chr$(0)) - 1)<br />

If hgstatus = 0 Then Print "The current user is " & hgvalue &<br />

"."<br />

hgstatus = HTTerm(0)<br />

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

We declare an hgstatus variable. All the status codes we get later will be<br />

put in the variable.<br />

Dim hgstatus As Long<br />

We declare hgvalue as a string which will store the user name of the Notes<br />

session.<br />

Dim hgvalue As String<br />

114 <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!