代码之家  ›  专栏  ›  技术社区  ›  Sidney

设置环境变量时,lotus脚本中何时需要“Set”

  •  0
  • Sidney  · 技术社区  · 7 年前

    我继承了一个项目的噩梦,那时候我只能假设LOC是lotus脚本中可以接受的KPI。在我被要求改变公司应用程序的工作方式后,我正在重构重复代码。下面的代码说明了我对Lotus脚本语法的一些不理解之处——我在domino设计器中遇到了一个错误,它位于“Control=UIDoc.Document…..”需要“集合”的行。查看现有代码,有时Set用于赋值,有时不用于赋值。我正在尝试阅读lotus脚本文档,但尚未找到差异的解释。有人能告诉我什么时候应该使用电视机,什么时候不应该使用电视机吗?如果有帮助的话,我有很强的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
    
    1 回复  |  直到 6 年前
        1
  •  3
  •   Richard Schwartz    7 年前

    这个 set 关键字与环境变量无关。这个 UIDoc.Document 方法返回 NotesDocument Set 指定对象引用时需要。标量变量的赋值 simple built-in data types (字符串、整数、布尔值、字节等)不需要 设置 .

    使用 设置 对于Notes产品类、任何OLE或COM类或在LotusScript本身中定义的任何类中的对象。