/*{{{*/Like的使用
挑出1-100之间包含3,但不包含2的数字:
for x=1 to 100
if CStr(x) Like "[!2]3" then print x
next x
/*}}}*/
/************************************************/
/*{{{*/收集数据库中所有文档
法1:利用Count 属性和GetNthDocument 方法遍历所有的文档
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Set db=session.CurrentDatabase
Dim dcollect As NotesDocumentCollection
Dim doc As NotesDocument
Set dcollect=db.AllDocuments
For j=1 To dcollect.Count
Set doc=dcollect.GetNthDocument(j)
Messagebox doc.subject(0)
Next
End Sub
法2:利用NotesDocumentCollection 的GetFirstDocument 和GetNextDoucment 方法
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Set db=session.CurrentDatabase
Dim dcollect As NotesDocumentCollection
Dim doc As NotesDocument
Set dcollect=db.AllDocuments
Set doc=dcollect.GetFirstDocument()
While Not(doc Is Nothing)
Messagebox doc.subject(0)
Set doc=dcollect.GetNextDocument(doc)
Wend
End Sub
/*}}}*/
/************************************************/
/*{{{*/取得域和它的值
取得一个已知域名称的域值:
法1:Set item=doc.GetFirstItem("policyName")
Messagebox item.Name & "=" & item.Text
法2: Forall cxt In doc.policyName
Messagebox cxt
End Forall
法3:Forall cxt In doc.GetItemValue("policyName")
Messagebox cxt
End Forall
/*}}}*/
/************************************************/
/*{{{*/域的添加/拷贝/删除/修改
添加
法1:Set item=new NotesItem(doc,"name",session.UserName)
法2:call doc.AppendItemValue("name",session.UserName)
拷贝
可以使用NotesItem 中的CopyItemToDocument 方法将当前的域拷贝到另外一个文档中.
用NotesDocument 中的CopyAllItems 方法将当前文档中的所有域拷贝到另一个域中.
用NotesDocument 中的CopoyItem 方法可以在想同的文档中将一个域拷贝到另一个域中.
删除
使用NotesItem 类中的Remove 方法或NotesDocument 类中的RemoveItem 方法从文档中删除一个域.
法1:While doc.HasItem("name")
Set Item=doc.GetfirstItem("name")
Call item.Remove
Call doc.Save(True,False)
Wend
法2:While doc.HasItem("name")
Call doc.RemoveItem ("name")
Call doc.Save(True,False)
Wend
修改
法1: Set Item=doc.GetfirstItem("name")
ItemValues=item.Values
Forall itemValue In ItemValues
ItemValue="刘晓"
End Forall
item.Values=itemValues
Call doc.Save (True,False)
法2: Call doc.ReplaceItemValue ("name","刘晓")
Call doc.Save (True,False)
/*}}}*/
/************************************************/
获取subject 字段的值/*{{{*/
Dim session As new NotesSession
Dim db As NotesDatebase
Dim view As NotesView
Dim doc As NotesDocument
Dim item As NotesItem
Set db=session.CurrentDatebase
Set view=db.GetView("main view")
Set doc=view.GetFirstDocument
Set item=doc.GetFirstItem("subject")/*}}}*/
/************************************************/
get the value of field "subject" in all document:{{{
Dim db As New NotesDatabase("Server","db.nsf")
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim item As NotesItem
Dim subject As String
Set dc=db.AllDocuments
Set doc=dc.GetFirstDocument()
While Not(doc Is Nothing)
Set item=doc.GetFirstItem("Subject")
subject=item.text
Set doc=dc.GetNextDocument(doc)
Wend}}}
/************************************************/
/*{{{*/@Subset
1.This example returns New Orleans;London.
@Subset("New Orleans":"London":"Frankfurt":"Tokyo";2)
2.This example returns London;Frankfurt;Tokyo.
@Subset("New Orleans":"London":"Frankfurt":"Tokyo";-3)
3.This example returns New Orleans;London;Frankfurt if the field named BranchOffices is made up of the list "New Orleans" : "London" : "Frankfurt" : "Tokyo" : "Singapore" : "Sydney."
@Subset(BranchOffices;3)
/*}}}*/
/************************************************/
/*{{{*/@ReplaceSubstring
1.This example returns "I hate apples."
@ReplaceSubstring( "I like apples" ; "like" ; "hate" )
2.This example returns "I hate peaches."
@ReplaceSubstring( "I like apples" ; "like" : "apples" ; "hate" : "peaches")
3.This example replaces all carriage returns in the Description field's text with blank spaces.
@ReplaceSubString(Description;@Newline;" ")
/*}}}*/
/************************************************/