Manning Logo
Home | Ordering Info | Shopping Cart | Manage My Account | Login
Attention customers: online shopping is now available exclusively through our main website: http://www.manning.com. Thank you.
Practical LotusScript

Inside the book

Sample Chapters Table of Contents Errata Index Preface Source Code Author Online

Manning Blog

Why small is sweet?

Author Blogs

Dave Crane more...

Author Calendar

Upcoming Events

Catalog

Java .NET Perl XML All by Subject All by Title

About...

Manning Contact Us Ordering FAQs ebooks Covers Sandbox Forums Distributors Manning Early Access Program (MEAP) Affiliate Program Academia/Publicity User Group Program Press Releases Jobs

Manning Publications Co.
209 Bruce Park Avenue
Greenwich, CT 06830

Practical LotusScript
Anthony Patton

1999 | 512 pages
ISBN: 1884777767
  $43.95 Softbound print book Out of Stock (?)

Errata

Example 2.23

Dim string1 As String, string2 As String
string1 = "Today was a good day."
string2 = "slow day."
Print "Before:  " & string1
Mid(string1, 13, 9) = string2
Print "After:  " & string1


Table 2.4

Return Value

Button

Constant

1

Ok

IDOK

2

Cancel

IDCANCEL

3

Abort

IDABORT

4

Retry

IDRETRY

5

Ignore

IDIGNORE

6

Yes

IDYES

7

No

IDNO


Example 2.27

Output should be:

33
29
31
33
31

The explanation section mentions String2 and String3, but they should be String1.


Example 2.28

Replace:

ElseIf (Right(LCase(answer),1) = "n") Then

With:

ElseIf (Right(LCase(answer),1) = "o") Then


Chapter 3 Example

Variable and code to set the top sales person is missing.  Declare public variable to store top salesperson?s name.

Public TopSalesPerson

Also, add code after third line of compareSalesAmount function that sets the TopSalesPerson variable.

TopSalesPerson = passedDoc.SalesPerson(0)


Example 4.1

Dim statement missing from declarations of dbTitle and dbSize

Dim dbTitle As String
Dim dbSize As Double


Example 4.7

Code for setName routine should be:

Me.Name = s


Example 4.9

Change line in Initialize section from...

.Name = "Student #" + x

to...

.Name = "Student #" + Cstr(x)


Chapter 4 Example

Numerous missing references to indexed object arrays.  The full code is below.

?Declarations Section

Public Class SalesPerson
     Private Name As String
     Private ID As String
     Private TotalSales As Currency
     Sub New
          With Me
               .Name = ""
               .ID = ""
               .TotalSales = 0
          End With
     End Sub
     Public Sub setName(s As String)
          Me.Name = s
     End Sub
     Public Function getName As String
          getName = Me.Name
     End Function
     Public Sub setID(s As String)
          Me.ID = s
     End Sub
     Public Function getID As String
          getID = Me.ID
     End Function
     Public Sub setTotalSales(c As Currency)
          Me.TotalSales = c
     End Sub
     Public Function getTotalSales As Currency
          getTotalSales = Me.TotalSales
     End Function
     Public Sub incTotalSales(amount As Currency)
          Me.TotalSales = Me.TotalSales + amount
     End Sub
End Class

? Initialize Section
Dim sp() As SalesPerson
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Set db = s.CurrentDatabase
Set dc = db.AllDocuments
Dim x As Integer
Dim y As Integer
Dim z As Integer
For x = 1 To dc.Count
Set doc = dc.GetNthDocument(x)
If (x=1) Then
Redim sp(0) As SalesPerson
sp(0).setName(doc.name(0))
sp(0).setID(doc.ID(0))
sp(0).setTotalSales(doc.Sales(0))
Else
Found = False
For y = 0 To Ubound(sp)
If (sp(y).getID = doc.Name(0)) Then
sp(y).incTotalSales(doc.Sales(0))
Found = True
End If
Next y
If Not (found) Then
Redim Preserve sp(Ubound(sp) + 1) As SalesPerson
sp(Ubound(sp) + 1).setName(doc.Name(0))
sp(Ubound(sp) + 1).setID(doc.ID(0))
sp(Ubound(sp) + 1).setTotalSales(doc.Sales(0))
End If
End If
Next x
For z = 1 To Ubound(sp)
Msgbox "Total sales for " + sp(z).getName + " is " + Cstr(sp(z).getTotalSales) + "."
Next z


Example 5.7

Dim s As New NotesSession
Dim db As New NotesDatabase("","")
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim sales List As Currency
If (db.Open("","Test2.nsf")) Then
Set dc = db.AllDocuments
If (dc.Count > 0) Then
Call dc.FTSearch(|FIELD Form =| & "Sales", 0)
For x = 1 To dc.Count
Set doc = dc.GetNthDocument(x)
If (doc.HasItem("SalesAmount") And doc.HasItem("SalesPerson")) Then
If (sales.IsElement(doc.SalesPerson(0))) Then
'I am getting error message when I try to save form, Illegal reference to array orlist:
Sales
sales(doc.SalesPerson(0)) =sales(doc.SalesPerson(0)) + doc.SalesAmount(0)
Else
sales(doc.SalesPerson(0)) = doc.SalesAmount(0)
End If
End If
Next x
End If
Forall y In sales
soutput$ = soutput$ + Listtag(y) + " - " + y + Chr(13)
'I hadto change output$ to soutput$, Notes did not like output$
End Forall
Messagebox soutput$, 0, "Results"
End If


Example 5.7

The code uses a variable called name, but this is a reserved word in LotusScript.  The variable name should be ?names?.


Example 5.14

A parenthesis was missing in the last if statement, and the Erase statement does not require parentheses around its argument  The corrected lines are...

If (Iselement(myList(search))) Then
Erase myList(search)


Example 5.17

The property used to check if the database is Full-Text Indexed is misspelled.  It is listed as IsFullText, but it should be IsFTIndexed.  The corrected line follows.

If (db.IsFTIndexed) Then


Example 5.23

The terms ?New? and ?As? are reversed in the declaration of the NotesUIWorkspace object.  It is the first line.

Dim uiw As New NotesUIWorkspace


Chapter 5 Example

Replace the line

If (sales.IsElement(doc.SalesPerson(0))) Then

With:

If (Iselement(sales(doc.SalesPerson(0)))) Then

Also, the variable output is seen as a reserved word in LotusScript so redefine it to some other term such as out.  It is used in two places.,

out = out + Listtag(y) + " - " + Cstr(y) + Chr(13)

and

Messagebox out, 0, "Results"


Example 6.17

Replace line:

Name destfile, renamefile

With

Name destfile As renamefile


Chapter 6 Example

Remove the line...

Dim db As New NotesDatabase


Example 7.4

The line instantiating the NotesUIWorkspace object should have the NEW keyword.

Dim uiw As New NotesUIWorkspace


Example 7.7

The second line after the first else statement is missing the ending quototation mark and parenthesis.

Call aLog.LogAction("There are 100 or fewer documents in this database")

Replace

Dim Log As NotesLog

With

Dim aLog As NotesLog


Example 7.11

Replace

Set aLog = New NotesLog( "Database log" )

With

Set aLog = New NotesLog( "Database log" )


Example 7.12

Replace

Call aLog.LogErrors("Another error has occurred.")

With

Call aLog.LogError(0,"Another error has occurred.")


Example 8.3

The line before the end of the While loop is missing.  The line retrieves the next document from the collection.  Without this line, the result is an infinite loop.

Dim uiw As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim lookupDoc As NotesDocument
Dim db As NotesDatabase
Dim view As NotesView
set uidoc = uiw.CurrentDocument
Dim NameList() As String
Set view = db.GetView("Names")
Set lookupDoc = view.GetFirstDocument
FirstTime = True
While Not (lookupDoc Is Nothing)
If (FirstTime) Then
Redim NameList(0) As String
FirstTime = False
Else
Redim Preserve NameList(Ubound(NameList) + 1) As String
End If
NameList(Ubound(NameList)) = lookupDoc.Name(0)
Set lookupDoc = view.GetNextDocument(lookupDoc)
Wend
uidoc.Document.Names = NameList
Call db.Close


Example 8.7

The If statement line is missing the ending parenthesis

If (Not (Source.EditMode)) Then


Example 9.5

The variable delete is declared, but delete is a reserved LotusScript keyword.  Replace all instances of the variable delete with your own name or use deleteIt. 

The second to last line in the entryOutput routine is missing a quotation before the word Delete.

outString3 = "Create personal folders: " & folders & Chr(13) & "Delete docs:  " & deleteIt

Also, the properties CanCreatePersonalAgents and CanCreatePersonalFolders is referenced in the entryOutput routine.  The correct spelling of the properties is without the trailing ?s?, so they should be referenced as CanCreatePersonalFolder and CanCreatePersonalAgent.


Example 9.6

Replace the line

aclEntry.CanCreatePersonalAgents = False

With

aclEntry.CanCreatePersonalAgent = False


Example 9.7

Corrected Code:

Dim s As New NotesSession
Dim db As NotesDatabase
Dim nACL As NotesACL
Dim rolesList As String
Set db = s.CurrentDatabase
Set nACL = db.ACL
rolesList = "List of roles for " & db.Title & Chr(13)
Forall v In nACL.Roles
rolesList = rolesList & v & Chr(13)
End Forall
Msgbox rolesList, 0, "Roles"


Example 10.1

The variable declared as ?name? conflicts with a LotusScript reserved word.  Rename all instances of name to newName.


Example 10.3

This will work with version 5.  The instantiation of the NotesDatabase object with this line.

Set db = uiw.CurrentDatabase

Replace with these two lines.

Dim s As New NotesSession
Set db = s.CurrentDatabase


Example 10.7

The object uidoc is improperly declared as a NotesDocument object; it should be declared as a NotesUIDocument object.

Dim uidoc As NotesUiDocument


Example 10.11

Replace

Call rtitem.AppendTab(1)

With

Call rtitem.AddTab(1)


Example 10.12

Replace:

rtStyle.Italics = False

With:

rtStyle.Italic = False


Example 11.4

Three lines of the listing have errors.  Here is the complete corrected listing.

Dim ns As New NotesSession
Dim ndb As NotesDatabase
Dim ndoc As NotesDocument
Dim neo As NotesEmbeddedObject
Dim nrtf As NotesRichTextItem
Dim ndc As NotesDocumentCollection
Dim filename As String
Dim count As Long
Set ndb = ns.CurrentDatabase
Set ndc = ndb.AllDocuments
For count = 1 to ndc.Count
    Set ndoc = ndc.GetNthDocument(count)
    If (ndoc.HasItem("Body") & (ndoc.HasEmbedded)) Then
        Set nrtf = ndoc.GetFirstItem("Body")
        filename = InputBox("Please enter the name of the file.")
        If (filename <> "") Then
            Set neo = nrtf.GetEmbeddedObject(filename)
            If Not (neo Is Nothing) Then
                MsgBox "The file was found.",0,"Found"
                Exit Sub
            End If
        End If
    End If
Next count


Example 11.5

The last MsgBox line is missing the middle parameter.  Here is the corrected line.

Msgbox "The file has been embedded.",0,"Success"


Example 11.12

The GetNthDocument method is missing the required index parameter.

Set doc = dc.GetNthDocument(x)


Example 12.6

The first line incorrectly spells the NotesUIWorkspace class as NotesWorkspace.


Example 12.8

Line 4 should use the outlookObject instead of the outlook object when calling the CreateItem method.

Dim outlookObject As Variant
Dim newMemo As Variant
Set outlookObject = CreateObject("Outlook.Application.")
If Not (outlookObject Is Nothing) Then
Set newMemo= outlookObject.CreateItem(0)

    If Not (newMemo Is Nothing) Then
        NewMemo.To = "baseline@aye.net"

        NewMemo.Subject = "Test message from Lotus Notes"
        NewMemo.Body = "This is the body of the message."
        Call NewMemo.PrintOut()
        Call NewMemo.Send()
    End If
    Call outlookObject.Quit()
End If


Example 13.4

The String variable type is misspelled when declaring searchString.


Example 13.8

The line containing the If statement is missing the Then statement.

If (dc.Count > 0) Then


Example 14.1

Remove the dash (-) from the line instantiating the NotesSession object.


Example 14.3

The flag variables (oneFlag, twoFlag, threeFlag, fourFlag, fiveFlag, sixFlag, and allFlag) set in the setFlags routine on page 225 must be declared in the Declarations section along with the classes on page 224.  In addition, the variables must be declared as Public so they are accessible by all other scripts.

[Declarations]
Public oneFlag As Variant
Public twoFlag As Variant
Public threeFlag As Variant
Public fourFlag As Variant
Public fiveFlag As Variant
Public sixFlag As Variant
Public allFlag As Variant

Also, the last End If statement is missing in the Click subroutine.  It goes between the End If and End Sub statements at the end of the code.


Example 14.4

Replace

Set new = New NotesNewsLetter(dc)

With

Set news = New NotesNewsLetter(dc)

Remove the first quotation mark from the second instance of this line.

Set dc = db.FTSearch(|(FIELD FORM = "salesRecord") OR (FIELD divisionName = "One")|,0)


Example 15.10

Replace

Loop Until ores.EndOfData

With

Loop Until ores.IsEndOfData


Example 15.11

Missing last End If, add it after the last End If in the code.


Section 17.3

The code listed for the Declarations section is missing lines, replace with this code.

Type STARTUPINFO
     cb As Long
     lpReserved As String
     lpDesktop As String
     lpTitle As String
     dwX As Long
     dwY As Long
     dwXSize As Long
     dwYSize As Long
     dwXCountChars As Long
     dwYCountChars As Long
     dwFillAttribute As Long
     dwFlags As Long
     wShowWindow As Integer
     cbReserved2 As Integer
     lpReserved2 As Long
     hStdInput As Long
     hStdOutput As Long
     hStdError As Long
End Type


Example 17.6

Add a space between ?As? and ?Variant? in the declaration of the username variable.


Chapter 20

Chapter 20 contains code errors that result from changes to the LotusScript language from the Beta to the Gold version.  These corrections will be posted at later date.

DESCRIPTION

Practical LotusScript covers the LotusScript programming language like no other book on the market. It starts with the core languge and proceeds to cover the specifics of Lotus Notes in complete detail. Advanced topics include report generation, working with the web, Office 97 integration, and 5.0 enhancements.

Practical LotusScript is designed for:

  • Lotus Notes developers, both experienced and inexperienced
  • Visual Basic programmers looking to get up to speed in the Notes environment
  • any developer wanting more information on the Notes/Domino development environment

ABOUT THE AUTHOR...

Anthony Patton has worked with Lotus Notes for more than five years and is a both a Certified Lotus Principle Application Developer and System Administrator. He is the president of BaseLine, Inc. which specializes in custom and commercial software development.
Home | Catalog | Privacy Policy | About Manning

© 2003-2006 Manning Publications Co.