Null缓冲区在layoutDXL比较模块脚本中调用diff(buffres,buff1,buff2,富文本位)

时间:2017-12-14 03:29:43

标签: ibm-doors

我正在编写一个最终应该从下拉菜单中运行的脚本。

此脚本的部分内容为:

  1. 搜索,其中包含当前模块的名称并为同名模块(正常工作)组合数据库
  2. 创建列并调用(3。)中描述的布局dxl的脚本(work-ish,但不是我的主要问题)
  3. 布局DXL,用于比较模块的对象。
  4. 以下是我目前的情况。我没有声明问题,除了我被告知我试图在diff()函数中的位置1,2和3中传入空缓冲区

    //===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。“对象文本”和那个。“对象文本”产生非空字符串。 DXL手册告诉我,我的分配方法是正确的。

    三周前我开始学习DXL,所以我还是有点新鲜。这让我感到难过,但在等待看是否有人有建议的时候,我会继续尝试不同的事情。

    提前感谢任何有时间提供帮助的人。

2 个答案:

答案 0 :(得分:1)

好!花了我一秒钟,但我想我弄清楚为什么你的第一部分代码失败了。

//===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""")而不是&# 39; 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

答案 1 :(得分:0)

好的,所以我找到了一个解决方案,不过为什么它是一个解决方案:我不能说。

基本上,我把这个过程放到一个函数中,我调用了thismod中的每个对象。

void CompareMod(Object o, Module thismod, Module thatmod) {
    Object thato

    Buffer diffResult = create
    Buffer thisotext = create
    Buffer thatotext = create

    for thato in thatmod do {
        if(o."Reqid" "" == thato."Reqid" "") {
            thisotext = o."Object Text"
            thatotext = thato."Object Text"
            diff(diffResult, thatotext, thisotext, "\\cf1\\strike", "\\cf3\\u1")
            displayRichWithColor(stringOf(diffResult))
            delete thatotext
            delete thisotext
            delete diffResult
        }
    }
}

for thiso in thismod do {
    CompareMod(thiso, thismod, thatmod)
}

除此之外,我还有一个我将要追求的新问题。我没有发布我期望的内容,而是显示类似文本框之间的差异,而是只获取与thismod中每个对象重复的那个对象中所有对象相同的部分的打印输出。

所以这是我要解决的新项目,我也会接受这方面的帮助,或者我将来会发布一个新问题。