设置环境变量时,莲花脚本何时需要 "Set"
When is "Set" required in lotus script when setting an environment variable
从我只能假设 LOC 是 lotus 脚本中可接受的 KPI 的日子开始,我就继承了一个项目的噩梦。在我被要求更改我们公司应用程序的工作方式后,我正在努力重构重复代码。下面的代码说明了一些我不了解 Lotus Script 语法的东西——我在 domino 设计器中收到一个错误,在 "Control = UIDoc.Document....." 行上需要 A "Set"。看现有代码,有时用Set赋值,有时不用。我正在尝试阅读莲花脚本文档,但尚未找到对差异的解释。有人可以告诉我什么时候应该使用 Set 什么时候不应该使用任何改变吗?如果有帮助,我有很强的 C# 背景,并且在 JS 和 PHP
等解释语言方面有一些经验
Class DeploymentType
Private ProductName As String
Private ControlSuffix As String
Private TypeHeader As String
Private Control As NotesRichTextItem
Sub new (Product As String, Suffix As String, Header As String, UIDoc As NotesUIDocument)
'These three assignments do not show an error without set
ProductName = Product
ControlSuffix = Suffix
TypeHeader = Header
'This assignment shows an error unless I prepend it with "Set"
Set Control = UIDoc.Document.GetFirstItem(ProductName + ControlSuffix)
End Sub
set
关键字与环境变量无关。 UIDoc.Document
方法returns中的一个对象NotesDocument class. Set
is required for assigning object references. Assignments to scalar variables with simple built-in data types(字符串、整数、布尔值、字节等)不需要Set
。
对来自 Notes 产品 类 的对象、任何 OLE 或 COM 类 或您在 LotusScript 本身中定义的任何 类 使用 Set
。
从我只能假设 LOC 是 lotus 脚本中可接受的 KPI 的日子开始,我就继承了一个项目的噩梦。在我被要求更改我们公司应用程序的工作方式后,我正在努力重构重复代码。下面的代码说明了一些我不了解 Lotus Script 语法的东西——我在 domino 设计器中收到一个错误,在 "Control = UIDoc.Document....." 行上需要 A "Set"。看现有代码,有时用Set赋值,有时不用。我正在尝试阅读莲花脚本文档,但尚未找到对差异的解释。有人可以告诉我什么时候应该使用 Set 什么时候不应该使用任何改变吗?如果有帮助,我有很强的 C# 背景,并且在 JS 和 PHP
等解释语言方面有一些经验Class DeploymentType
Private ProductName As String
Private ControlSuffix As String
Private TypeHeader As String
Private Control As NotesRichTextItem
Sub new (Product As String, Suffix As String, Header As String, UIDoc As NotesUIDocument)
'These three assignments do not show an error without set
ProductName = Product
ControlSuffix = Suffix
TypeHeader = Header
'This assignment shows an error unless I prepend it with "Set"
Set Control = UIDoc.Document.GetFirstItem(ProductName + ControlSuffix)
End Sub
set
关键字与环境变量无关。 UIDoc.Document
方法returns中的一个对象NotesDocument class. Set
is required for assigning object references. Assignments to scalar variables with simple built-in data types(字符串、整数、布尔值、字节等)不需要Set
。
对来自 Notes 产品 类 的对象、任何 OLE 或 COM 类 或您在 LotusScript 本身中定义的任何 类 使用 Set
。