Many times I find that I am writing code to copy a set of fields to another
set of fields with in the same document, or in a document in another database.
Syntactically there are at least three ways to do this.
The first way looks something like this:
Call document.ReplaceItemValue("FieldA",document.GetItemValue("FieldB"))
A second way is:
document.FieldA=document.FieldB(0)
The third way seems to be less common. I rarely see it used in articles,
presentations or templates. This method uses the With statement. The With
statement lets you refer to members of an object by replacing the object
name with a dot. Rather than using the above syntaxes to copy values from
one set of fields to another, you could write it this way:
Dim document as NotesDocument
With
document
.CompanyName = .Company(0)
.OrigDivision=.Division(0)
.OrigAdd1=.Address1(0)
.OrigCity=.City(0)
.OrigState=.State(0)
.OrigCountry=.Country(0)
.OrigZip=.Zip(0)
.OrigFax=.Fax(0)
.OrigPhone=.Phone(0)
End With
Instead of repeating document - the notes document object - twice in each
assignment statement, it is inferred by the dot before each field name.
This is just one way to use dot notation with objects when coding in LotusScript.
Comment posted by Sean Burgess06/25/2006 08:31:25 PM
Homepage: http://www.phigsaidwhat.com
I use the With option more than any other. Also very helpful for when you have very long Print statements or are outputting to a text file. I would be interested in knowing which option is better for performance.
Sean---
Comment posted by Carolyn Kraut04/02/2004 10:29:15 PM
Its always been true that using ReplaceItemValue provides better performance than something like:
doc.fieldA=doc.FieldB(0)
Since the assignment statements within the With option are a shorthand version for the assignment statement just above, it stands to reason that the With option's performance would be the same. My tests show that in fact this is true.
Using the example above and each of the formats I found that using ReplaceItemValue took .0078 seconds, the assignment statemnts took .0156 seconds, and the With statement also took 0156. For copying small data sets from one document to another I use With, but for everything else I use ReplaceItemValue.
Comment posted by Esa06/25/2006 08:31:52 PM
Homepage: http://NA
I have a question, how can I replace a string in text file with lotus script, I have a xml file which I have created with LS Agent, I retrieve the data from a view, now the problem is next time I want to send more information to the xml file I have one extra end tag i the xml file and then it won't work, is there some way to ower write it like "" or delete the string before my agent runs
Comment posted by Carolyn Kraut04/30/2004 11:46:18 PM
Homepage: http://www.sharedknowledgesystems.com
When you say you send more information to the xml file, are you appending data or updating the existing data in the file? Are you using the LotusScript XML classes or a parser like MSXML? From the results you've described I'm guessing that you aren't and that's the problem.






-