Lotus Notes中最重要的部分

 

 

Lotus Notes中最 重要的部分
Evaluate()在脚本中执行一个lotus公式语言,返回该公式语言返回的值。
3. (@Modified, @Date, @Weekday, @Today, @Adjust, @Yesterday)。该样例在上例的基础上做些修改,在指定“Yesterday”时要跳过周末。如果今天是星期一,则 y 被设置为今天的日期再减去 3 天;否则设置为昨天的日期。用 y 代替 @Yesterday 用于测试 @Modified date。
d := @Date(@Modified);
y := @If(@Weekday(@Today) = 2; @Adjust(@Today; 0; 0; -3; 0; 0; 0); @Yesterday);
FIELD ViewStatus := @If(d = @Today; "Today"; d = y; "Yesterday"; "Old");
SELECT @All
怎样判断一个RTF为空值
Function IsRTFNull(rtfield As String) As Integer
On Error Goto Errhandle
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
currentfield = uidoc.CurrentField
Call uidoc.GotoField(rtfield)
Call uidoc.SelectAll
Call uidoc.DeselectAll
If currentfield <> "" Then
Call uidoc.GotoField(currentfield)
End If
IsRTFNull = False
Exit Function
Errhandle:
Select Case Err
Case 4407
'the DeselectAll line generated an error message, indicating that the rich text field does     not contain anything
If currentfield <> "" Then
Call uidoc.GotoField(currentfield)
End If
IsRTFNull = True
Exit Function
Case Else
'For any other error, force the same error to cause LotusScript to do the error handling
Error Err
End Select
End Function
怎样返回一个数据的类型
Declarations
Class ReturnObj
Private m_stName As String
Private m_stType As String
Property Get NameVal As String
NameVal = m_stName$
End Property
Property Get TypeVal As String
TypeVal = m_stType$
End Property
Sub new( arg_stName$, arg_stType$ )
m_stName = arg_stName$
m_stType = arg_stType
End Sub
End Class
Function Test() As ReturnObj
Set Test = New ReturnObj( "Name", "Type" )
End Function
Initialize
Dim var
Set var = Test()
Msgbox( var.NameVal )
怎样判断一个文件目录是否存在
If Dir$(dirName, ATTR_DIRECTORY) = ""
Then     'Directory does not exist
Else
'Directory does exist
End If
怎样在lotusScript中运行代理
Set s = CreateObject("Notes.NotesSession"
Set db = s.GETDATABASE("", "db.nsf"
Set a = db.GETAGENT("SomeAgent"
Call s.SETENVIRONMENTVAR("AgentDocID", "ABCD"
Call a.RUN
怎样才能得到当前数据库的文件路径
Public Function
GetDatabasePath( db As Notesdatabase ) As String
Dim position As Integer
position = Instr( db.FilePath, db.FileName )
GetDatabasePath = Left( db.FilePath , position - 1 )
End Function
怎样比较两个日期型的域
mdate1V = document.DateField1(0)
mdate2V = document.DateField2(0)
If mdate1V < mdate2V Then
MsgBox "DATE 1 LESS THEN DATE 2"
Else
MsgBox "DATE 2 LESS THEN OR EQUAL TO DATE 1"
End If
在Script中做到@mailsend
Function SendMailMemo(sendTo As String, _
cc As String, _
bcc As String, _
subject As String, _
body As String, _
linkTo As NotesDocument) As Integer
On Error Goto ErrorHandler
Dim mailDb As New NotesDatabase("", ""
Dim mailDoc As NotesDocument
Dim rtItem As NotesRichTextItem
Call mailDb.OpenMail
If (mailDb.IsOpen = False) Then Call mailDb.Open("", ""
Set mailDoc = mailDb.CreateDocument
mailDoc.Form = "Memo"
mailDoc.SendTo = sendTo
mailDoc.CC = cc
mailDoc.BCC = bcc
mailDoc.Subject = subject
Set rtItem = mailDoc.CreateRichTextItem("Body"
Call rtItem.AppendText(body)
If Not(linkTo Is Nothing) Then
Call rtItem.AddNewLine(2)
Call rtItem.AppendDocLink(linkTo, "Double-click to open document"
End If
Call mailDoc.Send(False)
SendMailMemo = True
Exit Function
ErrorHandler:
Print "Error " & Str$(Err) & ": " & Error$
Resume TheEnd
TheEnd:
SendMailMemo = False
End Function
怎样用lotusScript启动附件
首先 使用EmbeddedObjects类将附件拆离到一个临时文件夹里,然后用shell命令语句运行它
怎样在lotusScript中创建一个姓名域、读者域、作者域
创建一个"specialType"姓名域
Dim variableName As New NotesItem( notesDocument, name$, value [,specialType%])
创建一个"Author"作者域
Dim TAuthor As New NotesItem(doc, "Author", Auths, AUTHORS)
TAuthor.IsSummary = True
修改了主文档后,怎样自动修改答复文档
Sub QuerySave(Source As Notesuidocument, Continue As Variant)
Dim Collection As NotesDocumentCollection
Dim Doc As NotesDocument
Dim Form, ParentStatus, Status As String
Set Doc = Source.Document
Set Collection = Doc.Responses
Set Doc = Collection.GetFirstDocument
ParentStatus = Source.FieldGetText("STATUS"
While Not ( Doc Is Nothing )
Form = Doc.GetItemValue("Form"(0)
Status = Doc.GetItemValue("Status"(0)
If (Form = "TASK"And (Status <> ParentStatus) Then
Call Doc.ReplaceItemValue( "STATUS", ParentStatus )
Call Doc.Save (True, False)
End If
Set Doc = Collection.GetNextDocument(Doc)
WendEnd
Sub
怎样及时取到 服务器的时间
dim doc as notesdocument
set doc = Serverdb.Createdocument
createDate = doc.Created
............
最后不要让该文档存盘
lotusScripts中怎样在字符串里加回车?
"aaa"+chr(10)+"bbb"
怎样屏蔽用户用Delete键删除文件
在数据库Script中的Querydocumentdelete中使用下列语句。
Continue=False
LotusScript 是完全面向对象的编程语言。它通过预定义的类与 Domino 接口。Domino 监控用户代码的编译和加载,并且自动包含 Domino 的类定义。
访问现有的对象最好使用 LotusScript,例如:根据其他文档的值来更改一个文档中的值。LotusScript 提供了一些公式没有的 功能,例如:操作数据库存取控制列表 (ACL) 的能力。
写script关键是取对象,查看对象的属性,所以你要学会看notes提供的Script帮助。下面是我收集的一些script例子。一般是比较技巧的程序,要学习一般script编写,请下载lotusScript学习库!
LotusScript 是完全面向对象的编程语言。它通过预定义的类与 Domino 接口。Domino 监控用户代码的编译和加载,并且自动包含 Domino 的类定义。
访问现有的对象最好使用 LotusScript,例如:根据其他文档的值来更改一个文档中的值。LotusScript 提供了一些公式没有的功能,例如:操作数据库存取控制列表 (ACL) 的能力。
写script关键是取对象,查看对象的属性,所以你要学会看notes提供的Script帮助。下面是我收集的一些script例子。一般是比较技巧的程序,要学习一般script编写,请下载lotusScript学习库!
如何辨别域中数据的类型?
Dim Item as NotesItem
set item=doc.getfirstitem("item"
if item.type=NUMBERS then
end if
怎样判断视图中没有文档?
set doc = vw.getfirstdocument()
if doc is nothing then
end if
如何将查询结果放到一个文件夹里?
下面是将搜索结果放到名叫newfolder的文件夹中,并跳转到该文件夹上
Sub Click(Source As Button)
Dim docs As notesdocumentcollection
Dim doc As notesdocument
...........
q=doc.query(0)
Set docs = db.ftsearch(q, 0)
Call docs.PutAllInFolder( "newfolder" )
Call w.OpenDatabase( "","","newfolder"
End Sub
如何删掉数据库中所有私有视图?
Dim session As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Set db=session.currentdatabase
Forall i In db.views
Set doc=db.getDocumentByUNID(v.universalID)
' 这个地方视图当作文档来处理,以便取到视图的一些属性。
viewflag=doc.getItemvalue("$flags"
If viewflag(0)="pYV" Then
' 视图属性中$flags为"pYV"的是私有视图。
Call i.remove
End If
End Forall
如何在Notes中调用ODBC数据源中的进程?
下面是一个利用ODBC调用access数据库(资料库)的script代码
Dim session As New NotesSession
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Set qry.Connection = con
Set result.Query = qry
con.ConnectTo("资料库"
qry.SQL = "SELECT * FROM 资料库"
result.Execute
If result.IsResultSetAvailable Then
Do
result.NextRow
id=result.GetValue("ID",id)
Loop Until result.IsEndOfData
result.Close(DB_CLOSE)
Else
Messagebox "Cannot get result set for AssetData"
Exit Sub
End If
con.Disconnect
End Sub
从后台刷新当前文档?
将当前文档先关闭后再打开
set doc=uidoc.document
......
call uidoc.save()
call uidoc.close()
set uidoc=ws.editdocument(doc)
获得当前视图中选择了的文档?
可以用 Notesdatabase 的 Unprocesseddocuments 属性。
Dim session As New notessession
Dim db As notesdatabase
Dim collection As notesdocumentcollection
Set db = session.currentdatabase
Set collection = db.UnprocessedDocuments
Unprocesseddocuments 其实很有用的
notes和Excel交换数据
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim excelApplication As Variant
Dim excelWorkbook As Variant
Dim excelSheet As Variant
Dim i As Integer
Set excelApplication = CreateObject("Excel.Application"
excelApplication.Visible = True
Set excelWorkbook = excelApplication.Workbooks.Add
Set excelSheet = excelWorkbook.Worksheets("Sheet1"
excelSheet.Cells(1,1).Value = "姓名"
excelSheet.Cells(1,2).Value = "年龄"
i = 1
Set db = session.CurrentDatabase
Set view = db.GetView("abc"
Set doc = view.GetFirstDocument
While Not(doc Is Nothing)
i = i + 1
excelSheet.Cells(i,1).Value = doc.ClassCategories(0)
excelSheet.Cells(i,2).Value = doc.Subject(0)
Set doc = view.GetNextDocument(doc)
Wend
excelSheet.Columns("A:B".Select
excelSheet.Columns("A:B".EntireColumn.AutoFit
excelWorkbook.SaveAs("Script 内容"
excelApplication.Quit
Set excelApplication = Nothing
在视图中怎样历遍所有的文档?
Dim db As New NotesDatabase( "Ankara", "current/projects.nsf" )
Dim view As NotesView
Dim doc As NotesDocument
Set view = db.GetView( "Open/By Due Date" )
Set doc = view.GetFirstDocument
While Not ( doc Is Nothing )
....................
Set doc = view.GetNextDocument( doc )
Wend
在scipt中如何调用公式
例如我们想要取服务器名的普通名,在script中用@name() ,假设server变量以取到服务器名称在script中用Evaluate可以运行公式,如:servername=Evaluate("@name([CN];server)"
怎样用script代理取到CGI变量
Dim session As New NotesSession
Dim doc As NotesDocument
Set doc = session.DocumentContext
Messagebox "User = " + doc.Remote_User(0)
如何使用Win32API隐藏菜单呢?
1. Declarations :
Declare Function GetActiveWindow Lib "user32.dll" () As Long
Declare Function SetMenu Lib "user32.dll" ( Byval hmenu As Long, Byval newmenu As Long ) As Integer
2.
Sub HiddenMenu()
Dim hwnd As Long
hwnd = GetActiveWindow()
Call SetMenu(hwnd,0)
End Sub

你可能感兴趣的:(Lotus Notes中最重要的部分)