0

私は DOORS および DXL スクリプトを初めて使用します (ここで必要になるかどうかはわかりません)。私がやろうとしているのは、絶対数をコピーする 2 つの個別のモジュールに新しい列を作成することです。これは簡単に聞こえると思いますが、問題が発生しているのは、ツールを使用してモジュールを PDF に変換し、変換する前にそれらを 1 つのモジュールに結合することです。これを行うと、絶対数が台無しになり、それが起こる余裕はありません。

より説明的: 次を含む列があります: '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 に答える