我为 DOORS 9.5 编写了一个脚本,它在 DOORS 模块中查找特定对象并将它们写入 csv 文件。但是,在特定数量的行之后,它停止在 csv 文件中写入,我只得到了我请求的对象的一半。 我正在使用我在互联网上找到的字符串替换功能。所以这可能是问题所在,或者 dxl 在 csv 文件中写入是否存在某种最大值?
如果有人能帮我解决这个问题,那就太好了,因为我无法在互联网上找到任何解决方案,也无法理解为什么这行不通。
// String replacement function
string replace (string sSource, string sSearch, string sReplace)
{
int iLen = length sSource
if (iLen == 0) return ""
int iLenSearch = length(sSearch)
if (iLenSearch == 0)
{
print "search string must not be empty"
return ""
}
// read the first char for latter comparison -> speed optimization
char firstChar = sSearch[0]
Buffer s = create()
int pos = 0, d1,d2;
int i
while (pos < iLen) {
char ch = sSource[pos];
bool found = true
if (ch != firstChar) {pos ++; s+= ch; continue}
for (i = 1; i < iLenSearch; i++)
if (sSource[pos+i] != sSearch[i]) { found = false; break }
if (!found) {pos++; s+= ch; continue}
s += sReplace
pos += iLenSearch
}
string result = stringOf s
delete s
return result
}
Module m = read(modulePath, false)
Object o
string s
string eval
Stream outfile = write("D:\\Python\\Toolbeta\\data\\modules\\test.csv")
for o in m do
{
eval = o."Evaluation Spec Filter"
if(eval == "Evaluation Step Object")
{
s = o."Object Text"
s = replace(s,"\n","\\n")
outfile2 << o."HierarchyNumber" ";" s "\n"
}
}
close outfile
请您参考如下方法:
我终于找到了问题的解决方案(我知道替换功能有点糟糕^^)。 dxl 脚本似乎有一个内部计时器。当计时器到时,即使进程仍在执行,脚本也会自动结束。所以我的脚本总是在 x 秒后停止,这就是我从未在我的 csv 文件中获取所有数据的原因。 如果您遇到同样的问题,请尝试 pragma runLim,0。它将计时器设置为无限制。您也可以通过将 0 替换为任意数字来选择计时器。 (就我的目的而言,2000000 最合适)。
感谢所有的回答和帮助
