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.