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.

hgstatus = HTDocumentSetProperty(hgdocument,<br />

HTDOCUMENT_STRICT_BIND, False)<br />

Then we close each document. If the document cannot be closed<br />

successfully, an error code is returned to hgstatus.<br />

hgstatus = HTDocumentClose(hgdocument, 0&)<br />

Creating a Document<br />

FTDocumentCreate function: Creates and opens a new document in the<br />

database. Once created, the document behaves like any other document.<br />

The new document will not have a valid document ID until written to disk<br />

with HTDocumentSave or HTDocumentClose. If the DELAY_COMMIT<br />

property is used when closing, a valid document ID will not be assigned<br />

until the containing database is closed.<br />

Example<br />

Creates a new empty document.<br />

Dim hgdatabase As Long<br />

Dim FormID As Long<br />

Dim hgdocument As Long<br />

Dim hgstatus As Long<br />

hgstatus = HTInit(0)<br />

hgstatus = HTDatabaseOpen("", "test.nsf", 0, hgdatabase)<br />

FormID = HTFormLocateByName(hgdatabase, "Main Topic")<br />

hgstatus = HTDocumentCreate(hgdatabase, FormID, hgdocument)<br />

hgstatus = HTDocumentClose(hgdocument, 0&)<br />

hgstatus = HTDatabaseClose(hgdatabase, HTDBCLOSEF_SAVE_DOCS)<br />

hgstatus = HTTerm(0)<br />

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

We need to specify a <strong>for</strong>m when we create a new document in the database.<br />

The <strong>for</strong>m can be specified by the <strong>for</strong>m ID. In HiTest, we present the <strong>for</strong>m ID<br />

as long.<br />

Dim FormID As Long<br />

After opening a database, we specify the <strong>for</strong>m ID by the <strong>for</strong>m name. Here<br />

we use the Main Topic <strong>for</strong>m of the TEST database.<br />

FormID = HTFormLocateByName(hgdatabase, "Main Topic")<br />

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