【问题标题】:IBM DOORS Copy text from columnIBM DOORS 复制列中的文本
【发布时间】:2014-06-11 14:56:38
【问题描述】:

我是 DOORS 和 DXL 脚本的新手(不确定这里是否需要它)。我要做的是在两个单独的模块中创建一个新列,以复制绝对数字。我知道这听起来很简单,但我遇到的问题是我使用一种工具将我的模块转换为 PDF,然后在这样做之前将它们组合成一个模块。这样做会弄乱绝对数字,我不能让这种情况发生。

更具描述性: 我有一列包含以下内容: 'REQ01: 4' 其中'REQ01:' 代表模块,'4' 代表绝对数。同样,我有'REQ02:4'。我需要将它们复制到各自的模块中,并确保它们在模块组合后不会更改。

我已经尝试过一些 DXL 脚本,这就是我想出的:

displayRich("REQ01: " obj."Absolute Number" "")

这适当地显示了该列,但再次不起作用,因为当我合并模块时绝对数字最终会发生变化。

非常感谢您的帮助,如果我遗漏了任何重要信息,我深表歉意。

【问题讨论】:

  • 我不确定你用什么工具来组合它们,所以很难说什么能解决你的问题。我会尝试改用 dxl 属性。基本上与列相同,但它应该保留值。如果您需要有关属性的 DXL 部分的帮助,请告诉我。

标签: ibm-doors


【解决方案1】:

这是最终对我有用的代码。

// DXL generated on 11 June 2014 by Attribute DXL wizard, Version 1.0

// The wizard will use the following comments on subsequent runs
// to determine the selected options and attributes. It will not
// take account of any manual changes in the body of the DXL code.

// begin parameters (do not edit)
// One attribute/property per line: true
// Show attribute/property names: false
// Include OLE objects in text: true
// Attribute: Object Text
// end parameters (do not edit)

Module m
AttrDef ad
AttrType at
m = module obj
ad = find(m,attrDXLName)
if(!null ad && ad.object)
{
    at = ad.type
    if(at.type == attrText)
    {
        string s
        Buffer val = create
        Buffer temp = create
        ad = find(m,"Object Text")
        if(!null ad)
        {
            probeRichAttr_(obj,"Object Identifier", temp, true)
            val += tempStringOf temp
        }
        obj.attrDXLName =  richText (tempStringOf val) 
        delete val
        delete temp
    }
}

【讨论】:

    【解决方案2】:

    有一个内置的“复制属性”脚本可以做到这一点。至少在我公司安装的版本中,它在 PSToolbox 中,也可以在菜单中找到 PSToolbox/attributes/copy.../betweenattributes... 你去:

    // Copy values from one attribute to another
    
    /*
    */
    
    /*
    PSToolbox Tools for customizing DOORS with DXL V7.1
    -------------------------------------------------
    DISCLAIMER:
    
    This programming tool has been thoroughly checked 
    and tested at all stages of its production. 
    Telelogic cannot accept any responsibility for 
    any loss, disruption or damage to your data or 
    your computer system that may occur while using 
    this script. 
    
    If you do not accept these conditions, do not use 
    this customised script.
    -------------------------------------------------
    */
    
    if ( !confirm "This script copies values from one attribute to another in the same module.\n" //-
                  "Use this to assist in changing the types of attributes.\n\n" //-
                  "It asks you to select the source and destination attributes.\n\n" //-
                  "It works by ... well, copying attribute values!\n\n" //-
                  "Continue?"
       )
    {
        halt
    } 
    
    #include <addins/PSToolbox/utensils/dbs.inc>
    
    const int MAXATTRS = 1000
    
    
    DB  copyAttrValsDB      = null
    DBE copyAttrValsFrom    = null
    DBE copyAttrValsTo      = null
    DBE copyAttrValsConfirm = null
    DBE copyAttrValsButt    = null
    
    string attrListFrom[MAXATTRS]
    string attrListTo[MAXATTRS]
    
    string confirmOpts[] = { "Yes", "Yes to all", "No", "No to all", "Cancel" }
    
    bool confirmDataLoss = true
    bool noToDataLoss    = false
    
    
    ///////////////////////////////////////////////////////////
    //  Call-backs
    
    void doAttrValsCopy(DB db) {
    
        // check attributes
        string fromAn = attrListFrom[get copyAttrValsFrom]
        string toAn   = attrListTo  [get copyAttrValsTo  ]
        if ( fromAn == toAn ) {
            ack "Cannot copy attribute to itself."
            return
        }
    
        // get confirmation
        if ( !confirm "Confirm copy of attribute '" fromAn "' to attribute '" toAn "'." ) {
            return
        }
    
    
        confirmDataLoss = get copyAttrValsConfirm
    
        // do copy
        Object o
        for o in current Module do 
        {
            Buffer oldVal = create()
            Buffer newVal = create()
    
            if      ( fromAn == "Object Identifier" ) newVal = identifier(o)
            else if ( fromAn == "Object Level"      ) newVal = level(o) ""
            else if ( fromAn == "Object Number"     ) newVal = number(o)
            else                                      newVal = richText o.fromAn
    
            oldVal = richText o.toAn
    
            if ( confirmDataLoss && !noToDataLoss && length(oldVal) > 0 && oldVal != newVal ) 
            {
                current = o
                refresh current
                int opt = query("About to lose attribute '" toAn "' = '" stringOf(oldVal) "' on current object.", confirmOpts)
                if ( opt == 1 ) confirmDataLoss = false
                if ( opt == 2 ) continue
                if ( opt == 3 ) noToDataLoss = true            
                if ( opt == 4 ) return            
            }
    
            if ( !confirmDataLoss || !noToDataLoss || length(oldVal) == 0 ) o.toAn = richText stringOf(newVal)
    
            delete(oldVal)
            delete(newVal)
        }
    
        hide copyAttrValsDB
    }
    
    
    
    ///////////////////////////////////////////////////////////
    //  Main program
    
    int numAttrsFrom = 0
    int numAttrsTo   = 0
    
    AttrDef ad
    for ad in current Module do {
        if ( ad.module ) continue
        string an = ad.name
        if ( canRead (current Module, an) ) attrListFrom[numAttrsFrom++] = an
        if ( canWrite(current Module, an) ) attrListTo  [numAttrsTo++  ] = an
    }
    
    attrListFrom[numAttrsFrom++] = "Object Identifier"
    attrListFrom[numAttrsFrom++] = "Object Level"
    attrListFrom[numAttrsFrom++] = "Object Number"
    
    
    copyAttrValsDB      = create "Copy attribute values"
    copyAttrValsFrom    = choice(copyAttrValsDB, "From:", attrListFrom, numAttrsFrom, 0)
    copyAttrValsTo      = choice(copyAttrValsDB, "To:",   attrListTo,   numAttrsTo,   0)
    copyAttrValsButt    = apply (copyAttrValsDB, "Copy", doAttrValsCopy)
    copyAttrValsConfirm = toggle(copyAttrValsDB, "Confirm on loss of data", true)
    
    show copyAttrValsDB
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多