LotusScript 学习笔记

 

 

/*{{{*/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;" ")
/*}}}*/
/************************************************/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Lotus Domino WEB 开发技术积累-DOC(313页) 1. 选取视图的列的内容 @Trim @DbColumn 6 2. 隐藏判断常用的命令 6 3. 判断当前用户是否是“某个组”的成员,然后来显示和隐藏 6 4. 在Lotus Domino 中显示图 6 5. 链接JS文件 6 6. 删除文档的方法 7 7. $$return 域的使用 8 8. 将表单设计为视图或导航器模板 9 9. 为 Web 定制“表单已处理”确认信息 10 10. 定制出错信息 11 11. $$HtmlHead几种常用的技巧 11 12. Domino Designer 模板表 12 13. 角色判断 13 14. 判断文档是否正在被修改 13 15. 在只读的方式下返回($$return 13 16. 刷新表单 14 17. 怎样在文档里存照片? 14 18. 后台lotusscript如何取得前台表单中复选框所选择的项目列表(b/s结构) 15 19. 试图的列公式:附件下载 15 20. 有没有好一点的分页处理代码 16 21. 同一用户重复登录 18 22. Return to sender 19 23. Agent to copy values from 1 form to another 在同一个数据库中进行 22 24. 超越OLE – 通过COM结合MS Office与Notes应用 23 25. 读写关系数据库资料 28 26. 视图---excel,表单---word 32 27. 关于Web上的检索问题 35 28. 如何使用Notes与关系数据库进行信息交互? 37 29. 如何在IE里面实现notes中的 对话框列表? 39 30. LotusDomino环境下编写Web浏览器多数据库检索程序 40 31. WINAPI函数 44 32. 用PowerBuilder访问Lotus Notes数据库 55 33. 如何在表单中加入计数器 58 34. 实现两个数据库间的数据追加 C/S 结构 60 35. 如何防止他人使用旧id和旧口令访问Domino服务器? 61 36. 在你的WEB站点上使用DOMINO群集 62 37. 在你的DOMINO WEB站点中插入.SWF文件 73 38. DOMINO R5的域搜索功能在WEB上的实现 77 39. Display Rich Text fields in a view 86 40. Auto-Launch a file attachment 87 41. Showing a response count without showing the responses 89 42. 常用的几个按钮收集 91 43. 在WEB上从视图删除文档技巧 93 44. 在Domino Designer中使用XML数据 96 45. 在Domino Designer上执行XML 100 46. Show single category view, the next stage 107 47. Checkboxes in a list box 108 48. Formatting a Notes view in HTML table for WEB 109 49. Jump to the end of a view (web agent) 111 50. Disabling actions until a page finishes loading 114 51. Web-based, fully customizable search 115 52. 从复选框中删除文档Deleting selected docs on Web 120 53. Debugging LotusScript Agents 121 54. Displays the contents of the Subject field in the first document in theExamples view. 124 55. Example: GetLastDocument method 125 56. Examples: GetNextDocument method 125 57. Example: GetFirstDocument method 126 58. Examples: FTSearch method 127 59. Examples: DeleteDocument method 128 60. Example: Deleting a document 129 61. Example: Creating a document 129 62. Examples: Locating documents within a view or folder 130 63. Example: Adding a document 135 64. Export to Excel 136 65. 连接ODBC 138 66. 特效 140 67. notes和Excel交换数据 141 68. NOTES的ODBC:(LS:DO) 142 69. Managing JavaScript "popup" windows 第一稿 144 70. HEAD元素使用集锦 147 71. 主页javascript特效19则 148 72. 关于创建、删除、编辑、打开和保存文档的 URL 命令 156 73. Domino URL 命令 158 74. 在打开有下面这段代码的页面时将会跳出一个468x60大小的小窗口 160 75. javascript的容错脚本 161 76. Web search with JavaScript 162 77. 如何防止他人使用旧id和旧口令访问Domino服务器 164 78. Fixing the Domino CheckBox Bug 165 79. Managing JavaScript "popup" windows 172 80. Quick, easy, foolproof field level help 175 81. Quick edit document link 176 82. Managing JavaScript "popup" windows 178 83. Svg: Pie-Eyed 181 84. Recebt Entries 182 85. Xin Calendar Mods 183 86. 答复文档 186 87. 公式语言 187 88. Resuable way to get URL parameters into fields 199 89. JSHeader 使用 201 90. JavaScript 帮助 201 91. Examples: Collecting documents by searching 207 92. 关于DOcumentContext 的属性 209 93. About data types 关于lotus Domino 的数据类型 210 94. CLng function 212 95. Using the DOM to replace "No documents found" 213 96. What you need and want to know about errors 217 97. Processing multiple documents from a view 221 98. Forcing attachments to always download 225 99. ODBCExample: GetValue method 247 100. ODBCResultSet class 248 101. Create a "Login" anchor link 251 102. 分类视图的开发技巧 253 103. 公式语言 255 104. Copy documents from one database to another 267 105. 定制搜索表单 268 106. UserName的属性及使用 275 107. Dynamic Content for Popup Windows 277 108. Shortcut when printing from a Java Agent 278 109. Lotus Script: Write # statement 279 110. Lotus Script: Input # statement 280 111. 使用代理生成 XML 284 112. 使用视图生成 XML 286 113. 执行算术运算 288 114. Keep URLs simple by making them relative 292 115. Quick, easy, foolproof field level help 294 116. Hiding attachments (without noscript tag!) 295 117. Listing search results in groups 296 118. 如何在表单中加入计数器? 300 119. 怎样限制一个WEB用户只有登陆才能使用数据库 302 120. Complete control when printing HTML from an agent 304 121. Simple multi-lingual forms using Domino 306 122. Stop double form submissions 308
对于LotusScript,除了Rich-Text域外的元素,如文本、单选框、列表框、复选框等,你可以用几乎相同的代码取得它们的值。例如:如果有一个“Location”域,不论它是何种类型,你都可以用下面的LotusScript代码取得它的值:   fieldVals = doc.Location   或者这样:   fieldVals = doc.GetItemValue("Location")   在LotusScript中,域的类型对于你要取值(值数组)的代码并不重要。但是在JavaScript中,不同类型的域除了显示选项(比如单选框、复选框或者文本)外,并不像在Notes里那样,它们是不同的类型的对象,每一个都要用不同的方式去引用。其实,那也不是绝对的,有些对象是相似的,但是引用过程并不像在LotusScript里那么流畅。   在JavaScript中,没有所谓的Rich-Text域,在HTML中更没有。Notes里提供了一个可以放在浏览器里的富文本Java(不是JavaScript)小程序,从而可以得到富文本的一些功能,但是你并不能用JavaScript来对它编程,而且它也不是一个真正的HTML对象类型。   更让Notes开发人员惊讶的是,在Web上还没有数字型或时间型的域。HTML的域都是文本型的。尽管你能用它们来收集数字信息,如数量或单价,而保存的数据依然是文本。为了像数字一样使用它,你必须把它转换成数字类型。另一个区别是在Web上没有计算域,但并不意味着你不能在你的表单里加入计算域。你可以加入计算域,计算值将会在Web页中显示,除非域是隐藏的。关键是即使域就在那里显示,而HTML通常的处理是没有定义域。如果你把test域改成计算域而不是可编辑的,在测试时你会发现其值是取不到的,我们可以对比下计算域和可编辑域生成的html代码:   计算域的时候生成的代码(js是取不到值的):      action="/weboa/ggxx/Dinner.nsf/test?OpenForm&Seq=1" name="_test">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值