由于某种原因,DXL 解释器没有考虑到我在 for 循环结束时递减 i 的事实。我试图通过更改“i”的值来浏览 arrObj[] 数组。我有一些按钮分别递增(对于下一个对象)和递减(对于前一个对象)值。用 while 循环做同样的事情会使应用程序崩溃。
有什么方法可以控制索引,或者 DXL 是否会始终记住以前的值并增加它(即使用户在代码中更改了它的值)。
这是我的代码片段:
for i in 0:(iTotalObj-1) do
{
sAuxType = arrObj[i]."ObjectType"
sAuxNr = number(arrObj[i]) " "
sAuxObjTxt = arrObj[i]."Object Text"
print "\nAfter FOR:"i ""
if sAuxType == "Test-Case" then
{
set(testContent,"Index number: (" number(arrObj[i]) ") -> " arrObj[i]."Object Heading" "")
set(expectedResults, " ")
fillRow(sTesterName,sCfgSW,sCfgHW,arrObj[i])
block(dtbox)
}
if sAuxType == "Test-Step" then
{
set(testContent,"Index number: (" number(arrObj[i]) ") -> " arrObj[i]."Object Text" "")
set(expectedResults,richTextWithOle(arrObj[i]."ExpectedResult"))
fillRow(sTesterName,sCfgSW,sCfgHW,arrObj[i])
block(dtbox)
}
if sAuxType == "Test-Case-Description" then
{
set(testContent,"Index number: (" number(arrObj[i]) ") -> " arrObj[i]."Object Text" "")
set(expectedResults, "Please check the description throroughly")
fillRow(sTesterName,sCfgSW,sCfgHW,arrObj[i])
block(dtbox)
arrObj[i].("TestResult " iTR "") = "n/a"
arrObj[i].("FR " iTR "") = "n/a"
}
i--
print "\nAfter DECREMENT:"i ""
}
在输出框中,我将得到以下信息:
After FOR:0
After DECREMENT:-1
After FOR:1
After DECREMENT:0
After FOR:2
After DECREMENT:1