0

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

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

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

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

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

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

4

2 回答 2

0

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

// 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
    }
}
于 2014-06-11T17:54:44.737 回答
0

有一个内置的“复制属性”脚本可以做到这一点。至少在我公司安装的版本中,它在 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
于 2018-08-31T18:43:03.763 回答