好的!花了我一秒钟,但我想我明白了为什么你的第一段代码失败了。
//===Relevant declarations===
Object thiso, thato
Module thismod, thatmod // these have been assigned using my search function
Buffer diffResult = create
Buffer thisotext = create
Buffer thatotext = create
//===The problem child===
for thiso in thismod do {
for that o in thatmod do {
if(thiso."Reqid" "" == thato."Reqid" "") {
thisotext = thiso."Object Text"
thatotext = thato."Object Text"
diff(diffResult, thatotext, thisotext, "\\cf1\\strike","\\cf3\\u1") // here lies issue number 1
displayRichWithColor(stringOf(diffResult)) // commented out atm
delete thatotext
delete thisotext
delete diffResult
}
}
}
这里的问题在于那些“删除”调用。第一次运行时,第一个匹配所有条件的对象( thiso."Reqid" "" == thato."Reqid" "" )将导致缓冲区被删除并清空。下一次成功的匹配只会抛出一个错误。
//===Relevant declarations===
Object thiso, thato
Module thismod, thatmod // these have been assigned using my search function
Buffer diffResult = create
Buffer thisotext = create
Buffer thatotext = create
//===The problem child===
for thiso in thismod do {
for thato in thatmod do {
if(thiso."Reqid" "" == thato."Reqid" "") {
thisotext = thiso."Object Text"
thatotext = thato."Object Text"
diff(diffResult, thatotext, thisotext, "\\cf1\\strike","\\cf3\\u1") // here lies issue number 1
displayRichWithColor(stringOf(diffResult)) // commented out atm
thatotext = ""
thisotext = ""
diffResult = ""
}
}
}
delete thatotext
delete thisotext
delete diffResult
这将清除比较之间的缓冲区,但不会破坏它们。我认为这种行为也导致了您的功能化示例中的问题 - 您重复创建和销毁缓冲区,而不是重新使用相同的缓冲区空间。
让我知道这是怎么回事!
编辑:查看您的问题,如果您将其嵌入到布局 dxl 中,您可能希望使用 (obj."Reqid" "" ) 而不是 'thiso in thismod' 循环。为每个对象评估布局 dxl,并且“obj”被有效地分配为调用布局 dxl 的对象的句柄。现在每个对象都在循环遍历每个对象。
编辑 2:示例代码
//===Relevant declarations===
Object thato
Module thatmod // these have been assigned using my search function
Buffer diffResult = create
Buffer thisotext = create
Buffer thatotext = create
//===The problem child===
for thato in thatmod do {
if(thiso."Reqid" "" == thato."Reqid" "") {
thisotext = obj."Object Text"
thatotext = thato."Object Text"
diff(diffResult, thatotext, thisotext, "\\cf1\\strike","\\cf3\\u1") // here lies issue number 1
displayRichWithColor(stringOf(diffResult)) // commented out atm
thatotext = ""
thisotext = ""
diffResult = ""
}
}
delete thatotext
delete thisotext
delete diffResult