【问题标题】:Null buffer calls for diff(buffres, buff1, buff2, rich text bits) in layoutDXL compare module script空缓冲区调用布局 DXL 比较模块脚本中的不同(缓冲区、buff1、buff2、富文本位)
【发布时间】:2017-12-14 03:29:43
【问题描述】:

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

这个脚本的部分是:

  1. 使用当前模块的名称并在数据库中梳理同名模块的搜索(工作)
  2. 创建列并调用 (3.) 中描述的布局 dxl 的脚本(工作正常,但不是我的主要问题)
  3. 比较模块对象的布局 DXL。

以下是我目前拥有的。除了被告知我试图在 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."Object Text" 和 thato."Object Text" 生成非空字符串。 DXL 手册显示我的分配方法是正确的。

我在三周前开始学习 DXL,所以我还是有点新。这让我很困惑,但我会继续尝试不同的事情,等待看看是否有人有建议。

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

【问题讨论】:

    标签: ibm-doors


    【解决方案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" "" ) 而不是 '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
    

    【讨论】:

    • 谢谢!我已经解决了这个问题以及我遇到的更新问题并继续前进,但我真的不明白为什么我的解决方案有效。您不仅提供了解决方案,还解释了为什么它是解决方案。我真的很感激!
    【解决方案2】:

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

    本质上,我将过程放入一个函数中,我为 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 中的每个对象重复的 thatmod 中所有对象相同的部分。

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

    【讨论】:

      猜你喜欢
      • 2020-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多