LS question

Hi, everybody:

I am new to LS. I have a code like this:

dim doc as notesdocument

.

.

.

set doc=db.createdocument

doc.form =“search”

doc.field1=doc.field1(0)

Anyone can explain the last two lines for me? I appreciate your help!

Subject: What you are seeing is the “Shorthand” notation for referencing and assigning Field values.

doc.Form = “search” is the same as:Call doc.ReplaceItemValue(“Form”, “search”)

v = doc.Field1 is the same as:

v = doc.GetItemValue(“Field1”)

since every item returned to LotusScript from a NotesDocument is returned as an array, you will see a lot of code like:

If doc.Field1(0) = “Yes” Then

Subject: LS question

The last two lines use “extended class syntax”. That allows you to use the document object as if each of its field were a property of the document. It’s a short way of saying:

Call doc.ReplaceItemValue(“Form”;“search”)

Call doc.ReplaceItemValue(“Field1”;doc.GetItemValue(“Field1”)(0))

The last line is a head-scratcher, unless the code actually looks like this:

newDoc.Field1 = thisDoc.Field1(0)

since the new document will not have any value in Field1 just after creation. As for the (0), Notes Items (fields) contain arrays, and this code only wants the first value (which could also be the only value) from the array.

Subject: RE: LS question

I got it. Thank you very much, Stan!