惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - james.dong

初次使用T4引擎生成数据库表实体 - james.dong - 博客园 加快大表关联查询的速度(oracle) DataTable 排序 - james.dong - 博客园 查询oracle数据库中所有视图和表的信息 日期验证正规表达式( YYYY-MM-DD YYYY-MM-DD hh:mm:ss YYYY/MM/DD) windows2000server下 iis 无法下载 .exe , .dll文件的解决办法。 - james.dong C#中datagridview使用技巧系列谈(-)让输入焦点从左到右收藏 oracle中创建自增字段 .net 序列化和反序列化自定义treenode类 LotusScript基本语法知识(一) LotusScript中Option 的含义 Lotusscript中Instr()函数的功能和用法 System.Xml.XmlDocument.SelectNodes() 查询不到节点问题? - james.dong - 博客园 Combox控件实现类似TextBox控件的ReadOnly=true时的背景颜色和字体颜色!(WinForm) WPF 中的 BitmapEffect 的 各种样式 WPF相关文章汇总 使用List泛型,怎么排序 asp.net2.0解决用户控件图片相对路径出错的问题,ResolveUrl的用法 window.showModalDialog()时没有显示修改后的数据 - james.dong - 博客园
LotusScript基础知识(二)
james.dong · 2008-12-05 · via 博客园 - james.dong

选择和循环语句

1.if语句

if condition1 then

   statement1

elseif condition2 then

  statement2

else

  statement3

end if

2.select case语句

select case  selectexpr

Case conditionList
  Statements
Case conditionList
  Statements
  …
Case Else
Statements
End Select

3.for语句
for conntvar=first to Last [Step increment]
statements
next [countvar]

4.while语句
While condition
  Statements
Wend

5.Do While/until Loop语句
永远循环
Do
Statements
Loop
先检查条件,再循环
Do while condition
  Statements
Loop
Do until condition
  Statements
Loop
先循环,后检查条件
Do
  Statements
Loop while condition
Do
  Statements
Loop until condition

6. Forall
ForAll refVar in container
  statements
End ForAll
例子:
Sub Click(Source As Button)
Dim short(5) As Integer 
Forall x In short
  x=1
End Forall
End Sub
结果:给short数组的每个元素赋值

中途退出循环
Exit LoopType
说明:looptype: for, while, do

子事例、函数、声明、作用域

1. 子事例
子事例也就是子过程,在编程窗格中单击一个按钮的click子事例就会打开如下click子事例:
Sub Click(Source As Button)
messagebox “hello word!”
End Sub
你可以在这个子事例中写出代码,如messagebox “hello word!” ,这是系统默认建立的一个单击子事例,同样的你可以建立自己的子事例如下:
Sub Click(Source As Button)
messagebox “hello word!”
  dim name=”lotus script”
  OutputName(name) ‘调用子事例OutputName
End Sub
Sub OutputName(name as string) ‘建立的新子事例,功能是输出参数name的值
Messagebox name
Sub
  输出结果为:弹出窗口lotus script
子事例是没有返回值的,函数的使用和子事例差不多,但是函数有返回值。如果想在子事例中返回一个值的话可以定义一个全局变量,然后给这个变量赋值就能达返回值的功能,如何定义一个全局变量将在作用域中讲到。

2. 函数
程序员都知道函数的作用,我就不多说了,这里只说明一下定义和使用的格式
Sub Click(Source As Button)
Dim a As Integer 
Dim b As Integer 
Dim c As Integer 

a=3
b=4
c=Sun(a,b) '使用求和函数得到a和b 的和
Messagebox Cstr(a)+"+"+Cstr(b)+"="+Cstr(c)
End Sub
Function Sun(a As Integer ,b As Integer ) As Integer '定义函数Sun, 功能是返回两个参数的和
c=a+b
sun=c '给函数名赋值就是这个函数的返回值。
End Function 
输出结果:弹出对话框a+b

3. 控制变量是否在需要声明才有效
如果用户在脚本的options部分中设置了option declare, 那么就一定要声明所有的变量,不管它们是什么类型。默认是可以不声明的,如下例:
例1 (没有设置 option declare)
Sub Click(Source As Button)
TestVar=”hello word !”
Messagebox TestVar
End Sub
输出结果为:(弹出对话框)hello word!
例2 (设置了 option declare)
Option Declare
Sub Click(Source As Button)
TestVar=”hello word !”
Messagebox TestVar
End Sub
在保存的时候就会出现错误:Variable not declared:TestVar

4. 作用域
LotusScript的作用域分为三个,从小到大分别为:子事例或函数、对象(如按钮、域等)、窗体(如表单、视图等)
  (1)子事例或函数
  如果在子事例或函数中定义的变量只能在此子事例或函数中使用,在另外一个是不能用的,如下:
  Sub Click(Source As Button)
Dim TestVar As String
Testvar="hello word!"
End Sub
Sub outputStr
Messagebox testvar
End Sub
输出结果:弹出对话框为无值
因为TestVar是在Click子事例中定义的,所以只能在Click子事例中使用,在OutputStr子事例中是不起作用的。

(2) 对象(如按钮、域等)
  在对象中定义的变量中能在此对象中使用,包括这个对象的所有子事例,在另外一个对象中是不能用的,如下:
  Dim TestVar as String ‘在(Declarations)中定义
  Sub Click(Source As Button)
  Testvar="hello word!"
End Sub
Sub outputStr
  Messagebox testvar
End Sub
输出结果:弹出对话框hello word!
因为TestVar是在对象中定义的,所以在这个对象中的所有子事例或函数都起作用。

  (3) 窗体(如表单、视图等)
在窗体中定义的变量可以在这个窗体中的任何对象中使用,如下:
‘(Globals)test 窗体 
Dim TestVar as String

Button1(按钮)
  Sub Click(Source As Button)
  Testvar="hello word!"
End Sub

‘Button2(按钮)
  Sub Click(Source As Button)  
  Messagebox Testvar
End Sub

  执行操作,先按Button1,再按Button2 
  输出结果为:弹出窗口hello word!
  因为TestVar是在test窗体中定义的,所以对这个窗体中的所有对象都是起作用的,Button1和Button2都是这个窗体的两个对象,先按Button1是给TestVar赋值,再按Button2是输出TestVar的值。