【问题标题】:VBScript Compilation Error - Expected SubVBScript 编译错误 - 预期的子
【发布时间】:2020-01-25 17:29:09
【问题描述】:

我有以下脚本不断接收

编译错误第 16 行 - 预期子

我不知道是什么原因造成的。

此脚本由 acscript 为 Avaya 电话系统运行。 ## cvs_cmd_begin## cvs_cmd_end 很可能被引擎替换为其他内容。

'SERVERNAME=123.45.67.89
Public Sub Main()
'## cvs_cmd_begin
' =========================================================
'  ERROR ERROR ERROR
'  If you're having trouble running a script make sure it's Encoding = UTF-8 (use Notepad++)
' =========================================================
'   On Error Resume Next

    SaveFolder = "K:\Telephony\ACD Automation\AutoReport.AgentInterval\Daily 20200124\"
    SaveFile = "Agent.Interval_20200124_12345.txt"

   cvsSrv.Reports.ACD = 1
   Set Info = cvsSrv.Reports.Reports("Historical\Designer\A.Agent Interval")

    If Info Is Nothing Then
        Exit
    Else
        b = cvsSrv.Reports.CreateReport(Info,Rep)

        If b Then
            Rep.TimeZone = "default"    
            Rep.SetProperty "Agent", "12345"
            Rep.SetProperty "Date", "1/24/2020"
            Rep.SetProperty "Times", "07:00-20:45"

            b = Rep.ExportData(SaveFolder & SaveFile, 9, 0, False, True, True)
                Rep.Quit
                Set Rep = Nothing
        End If
    End If

    Set Info = Nothing
'## cvs_cmd_end
End Sub

【问题讨论】:

  • 好吧,我刚刚注释掉了外部 If 块和 Set Info = 最后,它可以工作。如果脚本失败对我来说不是问题,因为它只是意味着报告没有返回任何数据,所以......
  • Exit 第 16 行是什么? Exit 后面总是跟着你正在退出的内容。
  • 但你并没有真正看到第 16 行。
  • @Mark 真的吗?没有意识到Exit 语句在代码中出现了不止一次,哦,是的,它没有。

标签: vbscript avaya


【解决方案1】:

问题在于Exit statement 的使用没有伴随的关键字。 Exit 语句有五种风格,具体取决于上下文。

  1. Exit Do
  2. Exit For
  3. Exit Function
  4. Exit Sub
  5. Exit Property

在这种情况下,如果未设置 Info 对象变量,代码将尝试退出子过程。解决方法是将第 16 行从

Exit

Exit Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多