Table of Contents

preface xvii

how this book is organized xviii

Author Online xx

special thanks xxi

1 Lotus Notes integrated development environment 1

1.1 Chapter objectives 2

1.2 Elements of the IDE 2

Colors 4, LotusScript Help 4, Errors 5, Debugging 5, Importing/Exporting 7, Printing 8, Limitations 8

1.3 Chapter summary 8

1.4 Chapter review 8

2 LotusScript basics--the foundation 11

2.1 Chapter objectives 12

2.2 Variables 13

Data Type Minimum/Maximum Value 13, Declaring and using variables 13, Constants 14, Explicit/Implicit 14, Options 15, Converting from one type to another 16, The special variable type: Variant 17, Determining the type of a variable 1 7

2.3 Indentifiers 18

2.4 Looping 19

For 19, Do 20, While 21, Forall 22

2.5 Other methods to affect code execution 22

If 22, Select Case 23, Stopping execution 23, Goto 24

2.6 Interacting with the user 25

Print 25, MessageBox 25, InputBox 28

2.7 Commenting your code 29

2.8 Strings 29

Mid(String2Change, starting_position, optional_length) = String2GetCharacters 30, UCase/LCase(string) 30, Len(String) 31, Trim/LTrim/RTrim(String) 31, Left(String)/Right(String) 32, Instr(optional_starting_point, string1, string2, op tional_compare_method) 32

2.9 Format function 33

2.10 Predefined constants 34

2.11 UnderScore (continuation) 34

2.12 Chapter summary 35

2.13 Chapter review 35

3 Functions and subroutines 37

3.1 Chapter objectives 38

3.2 Functions 38

3.3 Subroutines 40

Using subroutines 41, Creating your own function/subroutines 41, Built-in subs/functions 41

3.4 Scope/visibility 42

3.5 Chapter summary 44

3.6 Chapter review 44

4 Objects: working with classes 45

4.1 Chapter objectives 46

4.2 What is an object class? 46

Dot notation 47, Defining your own classes 48

4.3 Designing classes 48

Me 49, Creating the class 49, With ... End With 50, Constructors and destructors 51, Using classes, creating objects 52, Delete 53, Is, IsA, and IsObject 53, Garbage collection 54, Property (Get/Set) 54, Arrays of objects 55

4.4 Front-end/back-end classes 56

Front-end classes 57, NotesUIWorkspace 57, NotesUIDocument 57, Back-end classes 57, NotesSession 57, NotesDatabase 58, NotesView 58, NotesDocument 58

4.5 Chapter example 59

4.6 Chapter summary 60

4.7 Chapter review 61

5 Working with arrays, lists, collections, and items 63

5.1 Chapter objectives 64

5.2 Arrays 64

Forall 65, LotusScript statements 66, Dynamic arrays 67, Multidimension arrays 69, Variation 70, Limitations 71

5.3 Lists 71

ListTag 71

5.4 NotesDocumentCollection 74

5.5 Working with response documents 76

Number of documents 77, Traversing a collection 77, Refining a collection 78

5.6 NotesItem 79

HasItem 81

5.7 Chapter example 82

5.8 Chapter summary 84

5.9 Chapter review 84

6 Working with files 85

6.1 Chapter objectives 86

6.2 Opening 86

Freefile 87

6.3 Closing 88

6.4 Reading/writing 89

Reading 89, Writing 89, EOF (filenumber) 90, LOF (filenumber) 90, LOC (filenumber) 90

6.5 Sequential access 91

6.6 Random access 94

6.7 Binary access 97

6.8 Directories 98

Dir 98, CurDrive, ChDrive, CurDir, ChDir 100, More LotusScript for working with files 101

6.9 NotesDBDirectory class 102

Methods 102

6.10 Platforms 104

6.11 Chapter example 105

6.12 Chapter summary 107

6.13 Chapter review 107

7 Error processing and activity logging 109

7.1 Chapter objectives 110

7.2 Error trapping 110

Resume 111, Handling specific errors 111, Handling user-defined errors 112, Checking objects before referencing 112, More detailed error messages 113, Err, Erl, and Error 113, Scope 114, Logging activity 114

7.3 NotesLog 115

7.4 Setting up the NotesLog object 117

Logging to a Notes database 117, Logging to a text file 118, Logging via email 118, Actions 119

7.5 Errors 119

Logging script activity via the agent log 120

7.6 Chapter summary 122

7.7 Chapter review 122

8 Events 123

8.1 Chapter objectives 124

8.2 Initialize 124

8.3 Terminate 124

8.4 Forms/subforms 125

PostOpen 125, QueryOpen 126, QuerySave 127, QueryClose 128, PostRecalc 128, QueryModeChange 128, PostModeChange 129, WebQueryOpen 129, WebQuerySave 130

8.5 Fields 130

Entering 130, Exiting 130

8.6 Database (located in the database script) 131

PostOpen 131, QueryDocumentDelete 131, PostDocumentDelete 132, QueryDocumentUndelete 132, QueryClose 132

8.7 Action/button/hotspot 132

ObjectExecute 132, Click 132

8.8 Views/folders 133

QueryOpen 133, PostOpen 133, QueryOpenDocument 133, QueryRecalc 133, QueryAddToFolder 133, QueryPaste 134, PostPaste 134, QueryClose 134

8.9 Agents 134

8.10 Creating your own events 134

The flow of events 136

8.11 Chapter summary 140

8.12 Chapter review 140

9 Working with the ACL 141

9.1 Chapter objectives 142

9.2 Seven levels of access in the ACL. 142

Manager 142, Designer 142, Editor 142, Author 143, Reader 143, Depositor 143, No Access 143

9.3 NotesACL class 146

9.4 NotesACLEntry Class 147

9.5 Roles 150

9.6 UniformAccess 153

9.7 Chapter summary 153

9.8 Chapter review 154

10 NotesItem 155

10.1 Chapter objectives 156

10.2 NotesItem class 156

Creating items 156, Removing an item 157, Copying an item 158, Checking for a value 160

10.3 NotesItem object and its values 161

GetFirstItem 161, GetItemValue 161, Checking Values 162, Other properties 162, NotesRichTextItem 163, Accessing 164

10.4 Working with text 166

NotesRichTextStyle 167

10.5 Chapter summary 171

10.6 Chapter review 171

11 Embedded objects and OLE 173

11.1 Chapter objectives 174

11.2 Attachments 174

Creating an attachment 174

11.3 OLE 179

Linking 180, Embedding 180, OLE Automation 180

11.4 Creating embedded OLE objects 181

Creating an object 182, FYI 184

11.5 Creating a linked object 184

Editing an object 184

11.6 Deleting objects 185

11.7 Chapter summary 186

11.8 Chapter review 187

12 Office 97 189

12.1 Chapter objectives 190

12.2 Object browser revisited 190

12.3 Microsoft Office 190

Microsoft Word 191, Microsoft Excel 196, Microsoft PowerPoint 200, Microsoft Outlook 200

12.4 Performance considerations 203

12.5 Accessing Lotus Notes from Visual Basic 204

12.6 Chapter summary 205

12.7 Chapter review 205

13 Searching 207

13.1 Chapter objectives 208

13.2 Full-text indexing 208

Results 208, Search string rules 209, Logical operators 209, Trimming a collection 211

13.3 Searching a view 211

FTSearch 211, GetAllDocumentsByKey 212, GetDocumentByKey 213

13.4 Searching a database 213

FTSearch/UnprocessedFTSearch 213, Search/UnprocessedSearch 215, Creating a full-text index 216

13.5 Chapter summary 217

13.6 Chapter review 217

14 Reports 219

14.1 Chapter objectives 220

14.2 Reports as documents 220

Email 222, Scheduled 223, Selective/custom reports 223, MessageBox 224, Form as a Front-End 224, Newsletter 230

14.3 Chapter summary 233

14.4 Chapter review 233

15 LotusScript data objects 235

15.1 Chapter objectives 236

15.2 Domino.Connect 236

LS:DO 237, ODBC 237

15.3 SQL 238

SELECT 238, FROM 238, WHERE 238

15.4 ODBCConnection 239

15.5 ODBCQuery 241

15.6 ODBCResultSet 241

15.7 Handling errors 242

On Error 244

15.8 Accessing data in a result set 244

15.9 Adding/deleting records 246

15.10 Domino.Connect 248

15.11 NotesSQL 248

15.12 Chapter summary 249

15.13 Chapter review 249

16 Working with date/time values 251

16.1 Chapter objectives 252

16.2 LotusScript 252

16.3 Extracting portions of time/date values 253

16.4 NotesDateTime class 255

16.5 Methods 256

Creating a NotesDateTime object 259, NotesDateRange class 260, Year 2000 issues 261, NotesInternational class 264, Properties 264

16.6 Chapter summary 266

16.7 Chapter review 267

17 Working outside the Domino/Notes environment 269

17.1 Chapter objectives 270

17.2 Shell 270

Declare 272, Windows 95/NT 273, ActivateApp 274, Evaluate 275

17.3 Chapter summary 277

17.4 Chapter review 277

18 LotusScript and the Web 279

18.1 Chapter objectives 280

18.2 Print 280

18.3 Browsers 280

18.4 Environment variables 281

DocumentContext 282

18.5 Query_String 283

Events 286, WebQueryOpen 287, WebQuerySave 287, Executing agents 287, Web Navigator database(s) 287

18.6 Chapter summary 288

18.7 Chapter review 288

19 Input validation, NotesAgent class, and script libraries 291

19.1 Chapter objectives 292

19.2 Validation 292

Input validation 292, QuerySave event 292, Field exit event 293, Unique values 294, ComputeWithForm 295

19.3 NotesAgent class 296

19.4 RunOnServer 298

19.5 Script libraries 299

Using script libraries 300

19.6 Chapter summary 300

19.7 Chapter review 301

20 Notes 5.0 303

20.1 Chapter objectives 304

20.2 Integrated development environment 305

Performance 306, Forward references 308, Variable types 309, Threads 309, Classes 309, NotesOutline 309, NotesOutlineEntry 311, NotesOutline class methods 312, NotesOutlineEntry class properties 313, NotesUIWorkspace 313, User intera ction 314, File open 314, PickLists 314, Prompt 315, Spelling checker 316, NotesDocumentCollection 317, Generating HTML 318, NotesReplication 318, Replicating a database 320, NotesRichTextTab 321, NotesRichTextParagraphStyle 321, NotesViewEntryCollection 323, NotesUIView 324, NotesUIDatabase 325, NotesAgent 325, NotesACL/NotesACLEntry 326, Events 326, View 326, Document 327

20.3 Other enhancements 327

20.4 Chapter summary 327

20.5 Chapter review 328

21 Working with NotesPump 329

21.1 Chapter objectives 330

21.2 NotesPump classes 330

NPActivity 331, Creating an NPActivtiy 331, Deleting an NPActivity object 332, NPConnect 332, Methods 332, Creating an NPConnect object 333, Deleting an NPConnect object 333

21.3 NPFieldList 333

Properties 333, Methods 333, Creating an NPFieldList object 334, Deleting an NPFieldList object 334

21.4 NPField 336

Methods 336, Creating an NPField object 336, Deleting an NPField object 337

21.5 Data types 341

21.6 Conclusion 341

appendix A Notes/Domino constants 343

appendix B Notes/Domino classes 358

appendix C LotusScript keywords 474

index 481