gpt4 book ai didi

javascript - JavaScript/JScript 中缺少分号

转载 作者:行者123 更新时间:2023-11-28 12:02:55 25 4
gpt4 key购买 nike

我在 BRIO(Hyperion Interactive Reporting Studio)中编写了以下代码。代码要么是 JavaScript 要么是 JScript,但我不确定是哪一种,因为我刚刚学习语法并且不确定它们有何不同。

无论如何,我发现语法脚本(行号)丢失; before 语句以下几行出现错误:

if (xYear == 2012 && yMonth == 10) {stopIt = "Yes"} else (yMonth == 12) {stopIt = "Yes"}

var myDate = New Date(xYear, yMonth, 1)

在下面的代码中。

var xYear
var yMonth

for (j = 2009; j = 2012; j++)

{

xYear = j

if (xYear == 2009) {yMonth = 7} else {yMonth = 1}

var StopIt = "No"

Do

{
var myDate = New Date(xYear, yMonth, 1)
Alert (myDate)

//var myQuery = ActiveDocument.Sections["qry_billing"]

//myQuery.Limits["Accounting Year Month"].CustomValues.RemoveAll()
//myQuery.Limits["Accounting Year Month"].CustomValues.Add(myDate)
//myQuery.Limits["Accounting Year Month"].SelectedValues.Add(myDate)

//myQuery.Process()

//var Path = "W:\\Major Accounts\\Alliance Process\\AAA\\reference_files\\Results"
//var File = "Results" + "_" + xYear + "_" + yMonth+ " .txt"

//ActiveDocument.Sections["Results"].Export(Path + "\\" + File,bqExportFormatText,true)

yMonth = yMonth + 1

if (xYear == 2012 && yMonth == 10) {stopIt = "Yes"} else if (yMonth == 12) {stopIt = "Yes"}
}

While (stopIt != "Yes")

}

有人可以帮我解决这个问题吗,因为我不明白为什么它要求我提供 ;,因为我认为 BRIO 文档脚本中甚至不需要它。

最佳答案

else (yMonth == 12)

应该是:

else if (yMonth == 12)

当你正确缩进代码时,很容易注意到这个错误:

if (xYear == 2012 && yMonth == 10) {
stopIt = "Yes"
}
else (yMonth == 12) { // shoule be: else if (yMonth == 12) {
stopIt = "Yes"
}

注意:javascript区分大小写,这意味着

  • Do 不是 do
  • 至于alert而不是Alert
  • 而不是

但是分号不是强制性的,您可以根据需要使用或不使用它们。

更新:

从你发布的完整代码来看,伙计,它有很多奇怪的东西。

for (j = 2009; j =  2012; j++)

应该是这样的:

for (var j = 2009; j <= 2012; j++)
...

您定义一个变量:

var StopIt = "No"

但使用 stopIt 代替:

stopIt = "Yes"

你应该参加 javascript 类(class)\教程,学习起来并不难,但是你的代码在当前状态下完全损坏了!

关于javascript - JavaScript/JScript 中缺少分号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13236401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com