通过使用Links dxl DOORS复制对象来设置一个属性的新值

时间:2019-06-13 12:21:46

标签: attributes copying ibm-doors

我几乎没有dxl DOORS的经验,但是现在 我需要在一个模块内复制带有链接的对象,并通过复制设置属性之一的新值。 如何获得一次复制和设置新值的功能?

我找到了在DOORS的一个模块中复制带有子项的所选对象的代码。因此,我包含了用于设置属性的新值的对话框(例如,对象短文本)。它可以正常工作,但是有点奇怪。

pragma runLim,0
Module m = current
string targetModuleString = "Name of the Module"
string sourceModuleString = "Name of the Module"
Module sourceModule = read(sourceModuleString, false)
Object oObjectToCopy = current(sourceModule)
Module targetModule = edit targetModuleString
Object oObjectAsAnchor = current(targetModule)

 // object to copy
Skip skpListOfObjsToCopy = create()
int iNumObjs = 0
 void getListOfObjsToCopy(Object o, bool bWithHierarchy)
{if ( null o ) { return }

// add this object to the list
put(skpListOfObjsToCopy, iNumObjs++, o)
if ( bWithHierarchy ) {

// add children
Object oChild
for oChild in o do {
getListOfObjsToCopy(oChild, bWithHierarchy) 
} 
} 
}

void copyListOfObjects(Module mTarget, Object oAnchor, bool bCreateBelow)
{ if ( null mTarget ) { 
return 
}
current = mTarget
// set up array of anchor objects
// (assume maximum number of levels is 100)

Object oAnchors[100]
int i
for i in 0:9 do {
oAnchors[i] = null Object 
}
Object oLastObjectCopied = null Object
Object oLastObjectCreated = null Object
// need to work out the difference in the levels between the two modules
int iLevelDifference = 0 
// create the objects
bool bFirstObject = true
Object oSource
for oSource in skpListOfObjsToCopy do {
// determine where to create the new object
Object oTarget = null Object
if ( null oAnchor ) {
// create new level 1 object
oTarget = create (mTarget)
 }

else if ( null oLastObjectCreated ) {
if ( bCreateBelow )
 {
oTarget = create(below oAnchor) }
else {
oTarget = create(after oAnchor) 
}
}

else {
// create in relation to previous objects
if ( level(oLastObjectCreated) < level(oSource) + iLevelDifference ) {
oTarget = create(below oAnchor) 
}

else
{ oTarget = create(after oAnchors[level(oSource)])
} 
}

oAnchor = oTarget
oLastObjectCreated = oTarget
oLastObjectCopied = oSource
if ( bFirstObject ) {
// level difference is worked after we have created the first new object
iLevelDifference = level(oLastObjectCreated) - level(oLastObjectCopied)
bFirstObject = false 
} 

// keep a record of last object created at every level
oAnchors[level(oLastObjectCreated)] = oLastObjectCreated
 oLastObjectCreated."Object Heading" = richText(richTextWithOle oLastObjectCopied."Object Heading")
oLastObjectCreated."Object Text" = richText(richTextWithOle oLastObjectCopied."Object Text")
} 
}

// main program
getListOfObjsToCopy(oObjectToCopy, true)
copyListOfObjects(targetModule, oObjectAsAnchor, false)
DB exBox = create "Parameter value"
DBE strngIn = field(exBox, "Value of the parameter:","Example", 20)
void doSet(DB exBox) {
string s = get strngIn 
(current Object)."Object Short Text" = s 
}
apply(exBox,"Get", doSet)
show exBox

脚本设置了新值,但是要获得此新值,需要第二次运行脚本,而不是一步一步。

也许有一种方法可以对其进行优化,以便新值的设置只需一步就能完成?

0 个答案:

没有答案