我有一个模块A,其中的对象是从另一个模块B中的对象链接的。在A的视图中,我有一个布局DXL列,列出了所有这些链接的B对象:
// DXL generated by DOORS traceability wizard on 02 May 2016.
// Wizard version 2.0, DOORS version 9.2.0.5
pragma runLim, 0
string limitModules[1] = {"40fedbf2697f0e24-00003921"}
void showIter(Object o, string linkModName, int depth, string build, string iter) {
Link l
Object othero
for l in all(o<-linkModName) do { // ****
otherVersion = sourceVersion l
otherMod = module(otherVersion)
if (null otherMod || isDeleted otherMod) continue
if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
othero = source l
if (null othero) {
load(otherVersion,false)
}
othero = source l
if (null othero) continue
if (isDeleted othero) continue
doneOne = true
if (depth == 1) {
disp = ""
obuild = probeRichAttr_(othero,"Build", false)
oiter = probeRichAttr_(othero,"Iteration (planned)", false)
string ocat = othero."Category"
if (obuild == build && oiter == iter) {
s = "(B" obuild "." oiter " - " ocat[0] ") " (identifier othero)
disp = disp s
s = probeRichAttr_(othero,"Object Text", false)
disp = disp " " s
displayRich("\\pard " disp)
}
}
}
}
void showIn(Object o, int depth) {
Link l
LinkRef lr
ModName_ otherMod = null
Module linkMod = null
ModuleVersion otherVersion = null
Object othero
string disp = null
string s = null
string plain, plainDisp
int plainTextLen
int count
bool doneOne = false
Item linkModItem = itemFromID("40fedbf2697f0e24-000039a3")
if (null linkModItem) {
displayRich("\\pard " "<<Link module not found>>")
} else if (type(linkModItem) != "Link") {
displayRich("\\pard " "<<Invalid link module index for this database>>")
} else {
string linkModName = fullName(linkModItem)
for lr in all(o<-linkModName) do {
otherMod = module (sourceVersion lr)
if (!null otherMod) {
if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
load((sourceVersion lr),false)
}
}
}
//showIter(o, linkModName, depth, "1", "")
//showIter(o, linkModName, depth, "2", "")
showIter(o, linkModName, depth, "3", "3")
}
}
showIn(obj,1)
此脚本按对象ID /键按数字顺序列出链接对象:
B object with ID# 3
B object with ID# 8
B object with ID# 21
B object with ID# 24
然而在模块B中,没有任何排序活动,对象在插入顺序中是可见的,就像这样(即根据我插入的位置):
B object with ID# 24
B object with ID# 8
B object with ID# 21
B object with ID# 3
有没有办法以插入顺序循环B对象,即当没有排序处于活动状态时它们是否显示在B视图中?
答案 0 :(得分:0)
定义它的“自然”顺序是源对象在源模块中出现的顺序。这不包括源对象来自不同模块的情况,但这只是另一个问题..
循环“.. for l in ....”根据定义没有定义顺序,所以如果你需要一个,你必须定义自己的顺序。在DXL中,这通常由跳过列表完成。
您可以创建一个跳过列表,其键的类型为整数或字符串,值为Link类型。 然后,对于每个链接,您可以以某种方式计算正确的顺序,并添加一个条目,其中键表示顺序到跳过列表。稍后循环“for in in skip”将按键的顺序处理跳过列表。
在您的情况下,您可以借助于临时跳过列表(例如
)在所有源对象上使用循环来计算密钥。int order = 0
Skip skOrderOfObject = create()
Object o
for o in entire (... source module...) do {
order ++
int absno = o."Absolute Number"
put (skOrderOfObject, order, absno)
}
然后,要处理DXL列中的每个源对象,您可以执行
Skip skMySortedLinks = create()
...
for l in... {
Object oSource = source l
int iOrderOfThisObject
int absnoOfSource = oSource."Absolute Number"
find (skOrderOfObject, absnoOfSource, iOrderOfThisObject);
put (skMySortedLinks, iOrderOfThisObject, l)
}
最后
Link l
for l in skMySortedLinks do {
... print whatever you want to print...
}