Newbie to script could someone please explain this

Hi, I am just looking at a piece of script and I was hoping someone would be able to explain to me what i.name is? Is name some sort of property of i, even though i has not be declared as anythingMany thanks

For x = 1 To dc.Count

Set doc = dc.GetNthDocument (x)

Forall i In doc.Items

If (i.name = “lastname”) Then

Subject: Newbie to script could someone please explain this

The script is refering to Notes objects.

Objects have properties and method, as in any object oriented language.

i is refering to an item property on a document.

i.name is refering to the name property of the i object.

therefore, i.name is refering to:

NotesDocument → NotesItem → name property

As to what exactly is inside the name property, its syntax, or what is a NotesItem or a NotesDocument, you should refere to the Notes help files, it very well documented.

HTH

Nicolas Abesdris

Quintessence e-solutions Inc.

Subject: Newbie to script could someone please explain this

Forall i In doc.items

doc.items returns a notesitemarray and the variable i thus becomes an instance of the NotesItem class. The loop iterates for as many items as the doc contains. NotesItem properties and methods can thus be used over the “i” instance.

hope tht explains it

Subject: Newbie to script could someone please explain this

What the formula language calls a Field Lotusscript calls a notesitem. (Java, an item.) It’s the packet of data created in a document to store whatever the user types in a field.

A notesitem always stores an array of values. That array could have just one element. All the elements will be of the same datatype, as is required in lotusscript arrays.

A Notesitem has all sorts of useful methods and properties. For example if you want an item’s value and you know it’s a Text item you can say

msgbox notesitem.text

A notesdocument has a property items that returns an array of notesitems.(If there are any rich text items in the document I don’t think they show up here.)

A forall loop uses an implicitly declared variable of type Variant. Because we know the variant contains a notesdocument we can get notesdocument.name() on it.

As an aside, you should never do this:

For x = 1 To dc.Count

Set doc = dc.GetNthDocument (x)

’ do something

next x

Stepping through a notesdocumentcollection using getNthdocument is very slow. Use getNextDocument(doc) instead. One agent I say took 8 hours to run using this method; changing it to use getnextdocument() reduced that to 15 minutes.

set doc = dc.getfirstdocument

do while not doc is nothing

’ do something

set doc = dc.getnextdocument(doc)

loop