How to display selected attributes for selected levels in DOORS using DXL?

Hello! I'm looking for some DXL/DOORS help...

I have 3 modules: A, B, and C.  B is linked in to A, and C is linked in to B. So B is depth 1 and C is depth 2. I am trying to create a column in A that displays the object text, module name, and object number of the inlinked objects from B and C.  However, I do not want to display all 3 of these (text, name, number) for both B and C--instead I'd like to only display the object text from B and the module name and object number from C. Ideally I want the info from C to be in square brackets immediately following the info from B. I would like it to look like this:

Within a column in A:

"object text from B" ["module name of C" "object number of C"]

I have used the wizard to create the below layout DXL script, but currently it shows all 3 pieces of information for both B and C. Does anyone have any suggestions on how to print out only object text from B (depth 1), followed by module name and object number from C (depth 2)?

Note: In the below script, I tweaked the end to display s, p, and t in the order I would like them.

// DXL generated by DOORS traceability wizard on 27 October 2014.
// Wizard version 2.0, DOORS version 9.5.2.1
pragma runLim, 0
const int indentStep = 360
Buffer indentBuff = create
Buffer lineBuff = create
lineBuff = "______________________"
string indentAllParagraphs(string s, bool addBullets, int addedIndent)
{
    int numParas = 0
    RichTextParagraph rtp
    indentBuff = s
    for rtp in s do
    {
        numParas++
        Buffer t = create()
        t += rtp.text
        if (length(t) > 0 )
        {
            bool hasBullet = rtp.isBullet
            int  indentLev = rtp.indentLevel
            indentBuff = applyTextFormattingToParagraph(indentBuff, hasBullet, indentLev+addedIndent, numParas)
        }
        delete(t)
    }
    return (numParas == 0 ? "" : tempStringOf(indentBuff))
}
int lines[2] = {0, 0}
void adjustLines(int depth, showAtDepth) {
    int count
    for (count = 0; count < 2; count++) {
        while (lines[depth-1] < lines[count]) {
            if (depth == showAtDepth) displayRich("\\pard " " ")
            lines[depth-1]++
        }
    }
}
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
    string linkModName = "*"
    for lr in all(o<-linkModName) do {
        otherMod = module (sourceVersion lr)
        if (!null otherMod) {
            if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
                load((sourceVersion lr),false)
            }
        }
    }
    for l in all(o<-linkModName) do {
        otherVersion = sourceVersion l
        otherMod = module(otherVersion)
        if (null otherMod || isDeleted otherMod) continue
        othero = source l
        if (null othero) {
            load(otherVersion,false)
        }
        othero = source l
        if (null othero) continue
        if (isDeleted othero) continue
        int oldLines = lines[depth-1]
        doneOne = true
        {
            s = name(otherMod)
            p = probeRichAttr_(othero,"Object Number", false)
            t = probeRichAttr_(othero,"Object Text", false)
           displayRich(t" ""["s" "p"]")
        }
        lines[depth-1] += 3
        if ( depth < 2 ) {
            showIn(othero, depth+1)
        }
    }
}
showIn(obj,1)
delete indentBuff
delete lineBuff
 

 

 

 


sreed1141 - Mon Oct 27 19:28:49 EDT 2014

Re: How to display selected attributes for selected levels in DOORS using DXL?
sekrbo - Tue Oct 28 05:17:51 EDT 2014

If I understand you correctly, you want one line with information from two different objects. The linked object in module B and the linked object in module C. That would not be too difficult to achieve. However, there are some situations that you might have to handle.

1. If there is no link from module C, what should be displayed?

        "object text from B" [] ?

2. If there are multiple links from module C?

        "object text from B" ["module name of C" "object number x of C"]

        "object text from B" ["module name of C" "object number y of C"]

the easy way would then be to make the variables s, p and t global, set them in showIn depending on the value of depth like

if (depth == 1) then {
    t = probeRichAttr_(othero,"Object Text", false)
    s = ""
    p = ""
} else {
    s = name(otherMod)
    p = probeRichAttr_(othero,"Object Number", false)
}

the problem would then be to display the information. If there are links from C just add

displayRich(t" ""["s" "p"]")

last where you set s and p, but that leaves the situation where there is no linked object from C... which I suppose could be solved using a global boolean that is set to true every time you get an object at level 2 and set s and p, and is set to false where you set t. Then check if there was a C object after having called showIn for level 2. Something like

 
//  Global variables, remove from inside showIn
string p = null
string s = null
string t = null

bool bCobj = true

//  Inside showIn

if (depth == 1) then {
    t = probeRichAttr_(othero,"Object Text", false)
    s = ""
    p = ""
    bCobj = true
} else {
    s = name(otherMod)
    p = probeRichAttr_(othero,"Object Number", false)
    bCobj = false
    displayRich(t" ""["s" "p"]")
}

 ...

if ( depth < 2 ) {
    showIn(othero, depth+1)
    if (bCobj) then {
        displayRich(t" ""["s" "p"]")
    }
}

 

/sekrbo


 

Re: How to display selected attributes for selected levels in DOORS using DXL?
sreed1141 - Tue Oct 28 13:23:00 EDT 2014

sekrbo - Tue Oct 28 05:17:51 EDT 2014

If I understand you correctly, you want one line with information from two different objects. The linked object in module B and the linked object in module C. That would not be too difficult to achieve. However, there are some situations that you might have to handle.

1. If there is no link from module C, what should be displayed?

        "object text from B" [] ?

2. If there are multiple links from module C?

        "object text from B" ["module name of C" "object number x of C"]

        "object text from B" ["module name of C" "object number y of C"]

the easy way would then be to make the variables s, p and t global, set them in showIn depending on the value of depth like

if (depth == 1) then {
    t = probeRichAttr_(othero,"Object Text", false)
    s = ""
    p = ""
} else {
    s = name(otherMod)
    p = probeRichAttr_(othero,"Object Number", false)
}

the problem would then be to display the information. If there are links from C just add

displayRich(t" ""["s" "p"]")

last where you set s and p, but that leaves the situation where there is no linked object from C... which I suppose could be solved using a global boolean that is set to true every time you get an object at level 2 and set s and p, and is set to false where you set t. Then check if there was a C object after having called showIn for level 2. Something like

 
//  Global variables, remove from inside showIn
string p = null
string s = null
string t = null

bool bCobj = true

//  Inside showIn

if (depth == 1) then {
    t = probeRichAttr_(othero,"Object Text", false)
    s = ""
    p = ""
    bCobj = true
} else {
    s = name(otherMod)
    p = probeRichAttr_(othero,"Object Number", false)
    bCobj = false
    displayRich(t" ""["s" "p"]")
}

 ...

if ( depth < 2 ) {
    showIn(othero, depth+1)
    if (bCobj) then {
        displayRich(t" ""["s" "p"]")
    }
}

 

/sekrbo


 

Hi Sekrbo,

Thank you very much for your reply and help. Your answer worked great. I modified the very last part, so that if there is no inlink from C, only t is displayed. This way I don't have empty square brackets when there is no C inlink (better for my document formatting):

 if ( depth < 2 ) {
            showIn(othero, depth+1)
            if (bCobj) then {
                displayRich(t)
            }

I have a remaining issue though, which is something you asked at the beginning of your reply.

2. If there are multiple links from module C?

It's a little complicated because I actually have different C's (C1, C2...) linking in to any given object in B.  Also for the same C, I have different objects within it linking in to any given object in B. I would like these two situations to be handled differently, but I do not know if that's possible/difficult.

I would want it to look like below:

"object text from B" ["module name of C1" "object number x of C1"; "module name of C2" "object number x of C2"]

and

"object text from B" ["module name of C1" "object number x of C1", "object number y of C1"]

Further, these two sitautions often occur at the same time, where C1 and C2 objects are linking in to B, and multiple objects from C1 or C2 are linking in to B as well.

So overall, I would like it to look like:

"object text from B" ["module name of C1" "object number x of C1", "object number y of C1"; "module name of C2" "object number x of C2", "object number y of C2"]

Right now the way your script is written (which 100% addressed my first question), "object text from B" (variable t) gets displayed repeatedly for each inlinked C object, instead of just once followed by the list of many C objects. 

I realize this is more complicated than my original question, but I thought I would ask just in case you had any ideas. I appreciate it.

 

Re: How to display selected attributes for selected levels in DOORS using DXL?
sekrbo - Wed Oct 29 05:32:22 EDT 2014

sreed1141 - Tue Oct 28 13:23:00 EDT 2014

Hi Sekrbo,

Thank you very much for your reply and help. Your answer worked great. I modified the very last part, so that if there is no inlink from C, only t is displayed. This way I don't have empty square brackets when there is no C inlink (better for my document formatting):

 if ( depth < 2 ) {
            showIn(othero, depth+1)
            if (bCobj) then {
                displayRich(t)
            }

I have a remaining issue though, which is something you asked at the beginning of your reply.

2. If there are multiple links from module C?

It's a little complicated because I actually have different C's (C1, C2...) linking in to any given object in B.  Also for the same C, I have different objects within it linking in to any given object in B. I would like these two situations to be handled differently, but I do not know if that's possible/difficult.

I would want it to look like below:

"object text from B" ["module name of C1" "object number x of C1"; "module name of C2" "object number x of C2"]

and

"object text from B" ["module name of C1" "object number x of C1", "object number y of C1"]

Further, these two sitautions often occur at the same time, where C1 and C2 objects are linking in to B, and multiple objects from C1 or C2 are linking in to B as well.

So overall, I would like it to look like:

"object text from B" ["module name of C1" "object number x of C1", "object number y of C1"; "module name of C2" "object number x of C2", "object number y of C2"]

Right now the way your script is written (which 100% addressed my first question), "object text from B" (variable t) gets displayed repeatedly for each inlinked C object, instead of just once followed by the list of many C objects. 

I realize this is more complicated than my original question, but I thought I would ask just in case you had any ideas. I appreciate it.

 

That does make it more complicated. I would try using two skiplists, which are cleared for each module X object. Then for each C module, populate one list with the module name and the second with a concatenation of module name and object number for the key, and object number for the data. you would then have to remove all the displaying in the level two iteration and add an output in an else after if (bCobj). Here you would have to first find all of the C module names and then all of the objects in the second skiplist containing that module name in the key. I haven't tested it but something like this?

//  Global variables, remove from inside showIn
string p = null
string s = null
string t = null
string sKey  = null
string sDisp = null

bool bCobj = true
bool bFirst = true

Skip skCmod = createString
Skip skCobj = createString


//  Inside showIn

if (depth == 1) then {
    t = probeRichAttr_(othero,"Object Text", false)
    s = ""
    p = ""
    bCobj = true
    bFirst = true
    delete (skCmod)
    delete (skCobj)
    skCmod = createString
    skCobj = createString
} else {
    s = name(otherMod)
    p = probeRichAttr_(othero,"Object Number", false)
    bCobj = false
    put (skCmod, s, s)
    put (skCobj, s p, p)
}
 ...

if ( depth < 2 ) {
    showIn(othero, depth+1)
    if (bCobj) then {
        displayRich(t)
    } else {
        sDisp = null
        for s in skCmod do {
            if (bFirst) then {
                sDisp = " [" s
                bFirst = false
            } else {
                sDisp = sDisp "; " s
            }
            for p in skCobj do {
                sKey = (string key skCobj)
                if (sKey[0:length(s) - 1] == s) then {
                    sDisp = sDisp ", " p
                }
            }
        }
        sDisp = sDisp "]"
        displayRich(t sDisp)
    }
}

Now these deleting and creating skiplists,  I don't know how efficient that is, I really would like to find a perm empty (Skip sk)!

 

/sekrbo

Re: How to display selected attributes for selected levels in DOORS using DXL?
Mike.Scharnow - Wed Oct 29 05:46:16 EDT 2014

sekrbo - Wed Oct 29 05:32:22 EDT 2014

That does make it more complicated. I would try using two skiplists, which are cleared for each module X object. Then for each C module, populate one list with the module name and the second with a concatenation of module name and object number for the key, and object number for the data. you would then have to remove all the displaying in the level two iteration and add an output in an else after if (bCobj). Here you would have to first find all of the C module names and then all of the objects in the second skiplist containing that module name in the key. I haven't tested it but something like this?

//  Global variables, remove from inside showIn
string p = null
string s = null
string t = null
string sKey  = null
string sDisp = null

bool bCobj = true
bool bFirst = true

Skip skCmod = createString
Skip skCobj = createString


//  Inside showIn

if (depth == 1) then {
    t = probeRichAttr_(othero,"Object Text", false)
    s = ""
    p = ""
    bCobj = true
    bFirst = true
    delete (skCmod)
    delete (skCobj)
    skCmod = createString
    skCobj = createString
} else {
    s = name(otherMod)
    p = probeRichAttr_(othero,"Object Number", false)
    bCobj = false
    put (skCmod, s, s)
    put (skCobj, s p, p)
}
 ...

if ( depth < 2 ) {
    showIn(othero, depth+1)
    if (bCobj) then {
        displayRich(t)
    } else {
        sDisp = null
        for s in skCmod do {
            if (bFirst) then {
                sDisp = " [" s
                bFirst = false
            } else {
                sDisp = sDisp "; " s
            }
            for p in skCobj do {
                sKey = (string key skCobj)
                if (sKey[0:length(s) - 1] == s) then {
                    sDisp = sDisp ", " p
                }
            }
        }
        sDisp = sDisp "]"
        displayRich(t sDisp)
    }
}

Now these deleting and creating skiplists,  I don't know how efficient that is, I really would like to find a perm empty (Skip sk)!

 

/sekrbo

> I really would like to find a perm empty (Skip sk)!

there is one. It's undocumented, but works without any problem since v8.2

 

perm versions return type name parNr parType parname

 

void setempty (Skip) V8.2,V8.3,V9.1-0,V9.2-1,V9.2-2,V9.3-0 void setempty 0 Skip  

Re: How to display selected attributes for selected levels in DOORS using DXL?
sekrbo - Wed Oct 29 05:54:23 EDT 2014

Mike.Scharnow - Wed Oct 29 05:46:16 EDT 2014

> I really would like to find a perm empty (Skip sk)!

there is one. It's undocumented, but works without any problem since v8.2

 

perm versions return type name parNr parType parname

 

void setempty (Skip) V8.2,V8.3,V9.1-0,V9.2-1,V9.2-2,V9.3-0 void setempty 0 Skip  

Interesting! As you said undocumented, the only setEmpty in the DXL Help is void setempty(Buffer b)!

Then again probeRichAttr is undocumented as well :)

/sekrbo

Re: How to display selected attributes for selected levels in DOORS using DXL?
sreed1141 - Wed Oct 29 13:07:01 EDT 2014

sekrbo - Wed Oct 29 05:54:23 EDT 2014

Interesting! As you said undocumented, the only setEmpty in the DXL Help is void setempty(Buffer b)!

Then again probeRichAttr is undocumented as well :)

/sekrbo

Sekrbo, that worked exactly as hoped. Thank you for your time and reply. It is really generous that people on this forum provide answers to those of us who are trying to learn how to program

Re: How to display selected attributes for selected levels in DOORS using DXL?
sreed1141 - Wed Oct 29 20:40:02 EDT 2014

sekrbo - Wed Oct 29 05:32:22 EDT 2014

That does make it more complicated. I would try using two skiplists, which are cleared for each module X object. Then for each C module, populate one list with the module name and the second with a concatenation of module name and object number for the key, and object number for the data. you would then have to remove all the displaying in the level two iteration and add an output in an else after if (bCobj). Here you would have to first find all of the C module names and then all of the objects in the second skiplist containing that module name in the key. I haven't tested it but something like this?

//  Global variables, remove from inside showIn
string p = null
string s = null
string t = null
string sKey  = null
string sDisp = null

bool bCobj = true
bool bFirst = true

Skip skCmod = createString
Skip skCobj = createString


//  Inside showIn

if (depth == 1) then {
    t = probeRichAttr_(othero,"Object Text", false)
    s = ""
    p = ""
    bCobj = true
    bFirst = true
    delete (skCmod)
    delete (skCobj)
    skCmod = createString
    skCobj = createString
} else {
    s = name(otherMod)
    p = probeRichAttr_(othero,"Object Number", false)
    bCobj = false
    put (skCmod, s, s)
    put (skCobj, s p, p)
}
 ...

if ( depth < 2 ) {
    showIn(othero, depth+1)
    if (bCobj) then {
        displayRich(t)
    } else {
        sDisp = null
        for s in skCmod do {
            if (bFirst) then {
                sDisp = " [" s
                bFirst = false
            } else {
                sDisp = sDisp "; " s
            }
            for p in skCobj do {
                sKey = (string key skCobj)
                if (sKey[0:length(s) - 1] == s) then {
                    sDisp = sDisp ", " p
                }
            }
        }
        sDisp = sDisp "]"
        displayRich(t sDisp)
    }
}

Now these deleting and creating skiplists,  I don't know how efficient that is, I really would like to find a perm empty (Skip sk)!

 

/sekrbo

Hello again,

I have been trying to make an edit to the code you provided, and I have tried lots of different ideas, but I cannot seem to get it to work. In the code you provided, the output looks like:

"object text from B" ["module name of C1", "object number x of C1", "object number y of C1"; "module name of C2", "object number x of C2", "object number y of C2"]

But I actually need the commas after the module names to be gone... More like this:

"object text from B" ["module name of C1" "object number x of C1", "object number y of C1"; "module name of C2" "object number x of C2", "object number y of C2"]

I realize this is a very small difference, but it is pretty crucial. I thought it would be an easy fix, but I have not yet been able to get it working. I have tried adding in an addition boolean and if statement in the for loop for p. I have also tried moving this new if statement around in different places/orders. What I want to say is:

if p follows s, display p

but if p follows p, display ", " p

This way there would be no comma between s and p, and only a comma between p and the next p, as desired. 

Right now, my code I believe says:

the first p that occurs, display p

all following p, display ", " p

Here it is:

//  Global variables, remove from inside showIn
string p = null
string s = null
string t = null
string sKey  = null
string sDisp = null
string pDisp = null
bool bCobj = true
bool bFirst = true
bool bFollows = true
Skip skCmod = createString
Skip skCobj = createString

...

// inside showIn

  {
            if (depth == 1) then {
                t = probeRichAttr_(othero,"Object Text", false)
                s = ""
                p = ""
                bCobj = true
                bFirst = true
                bFollows = true
                delete (skCmod)
                delete (skCobj)
                skCmod = createString
                skCobj = createString
            } else {
                s = name(otherMod)
                p = probeRichAttr_(othero,"Object Number", false)
                bCobj = false
                put (skCmod, s, s)
                put (skCobj, s p, p)
            }            
        }
        lines[depth-1] += 3
        if ( depth < 2 ) {
            showIn(othero, depth+1)
            if (bCobj) then {
                displayRich(t)
            } else {
                sDisp = null
                pDisp = null
                for s in skCmod do {
                    if (bFirst) then {
                        sDisp = " [" s
                        bFirst = false
                    } else {
                        sDisp =  sDisp "; " s
                    }
                    for p in skCobj do {
                        if (bFollows) then {
                            pDisp = p
                            bFollows = false
                        } else {
                            pDisp = ", " p
                        }
                        sKey = (string key skCobj)
                        if (sKey[0:length(s) - 1] == s) then {
                            sDisp = sDisp pDisp
                        }
                    }
                }
                sDisp = sDisp "]"
                displayRich(t sDisp)
            }
        }
 

Any insight about this? I hope I am not taking advantage of your helpfulness. I can always post it back on the main forum.

 

Re: How to display selected attributes for selected levels in DOORS using DXL?
sekrbo - Fri Oct 31 16:42:47 EDT 2014

sreed1141 - Wed Oct 29 20:40:02 EDT 2014

Hello again,

I have been trying to make an edit to the code you provided, and I have tried lots of different ideas, but I cannot seem to get it to work. In the code you provided, the output looks like:

"object text from B" ["module name of C1", "object number x of C1", "object number y of C1"; "module name of C2", "object number x of C2", "object number y of C2"]

But I actually need the commas after the module names to be gone... More like this:

"object text from B" ["module name of C1" "object number x of C1", "object number y of C1"; "module name of C2" "object number x of C2", "object number y of C2"]

I realize this is a very small difference, but it is pretty crucial. I thought it would be an easy fix, but I have not yet been able to get it working. I have tried adding in an addition boolean and if statement in the for loop for p. I have also tried moving this new if statement around in different places/orders. What I want to say is:

if p follows s, display p

but if p follows p, display ", " p

This way there would be no comma between s and p, and only a comma between p and the next p, as desired. 

Right now, my code I believe says:

the first p that occurs, display p

all following p, display ", " p

Here it is:

//  Global variables, remove from inside showIn
string p = null
string s = null
string t = null
string sKey  = null
string sDisp = null
string pDisp = null
bool bCobj = true
bool bFirst = true
bool bFollows = true
Skip skCmod = createString
Skip skCobj = createString

...

// inside showIn

  {
            if (depth == 1) then {
                t = probeRichAttr_(othero,"Object Text", false)
                s = ""
                p = ""
                bCobj = true
                bFirst = true
                bFollows = true
                delete (skCmod)
                delete (skCobj)
                skCmod = createString
                skCobj = createString
            } else {
                s = name(otherMod)
                p = probeRichAttr_(othero,"Object Number", false)
                bCobj = false
                put (skCmod, s, s)
                put (skCobj, s p, p)
            }            
        }
        lines[depth-1] += 3
        if ( depth < 2 ) {
            showIn(othero, depth+1)
            if (bCobj) then {
                displayRich(t)
            } else {
                sDisp = null
                pDisp = null
                for s in skCmod do {
                    if (bFirst) then {
                        sDisp = " [" s
                        bFirst = false
                    } else {
                        sDisp =  sDisp "; " s
                    }
                    for p in skCobj do {
                        if (bFollows) then {
                            pDisp = p
                            bFollows = false
                        } else {
                            pDisp = ", " p
                        }
                        sKey = (string key skCobj)
                        if (sKey[0:length(s) - 1] == s) then {
                            sDisp = sDisp pDisp
                        }
                    }
                }
                sDisp = sDisp "]"
                displayRich(t sDisp)
            }
        }
 

Any insight about this? I hope I am not taking advantage of your helpfulness. I can always post it back on the main forum.

 

I think the problem is that the second bool bFirst is about the 'inner itteration' the output that you are creating for each C module, therefore you cannot set bFirst = true for each B object. That is you have to set it for each Cmodule, and that is in the first skiplist loop. So add this

 for s in skCmod do {
    bFollows = true
    if (bFirst) then {

and remove the one in

// inside showIn

  {
            if (depth == 1) then {
                t = probeRichAttr_(othero,"Object Text", false)
                s = ""
                p = ""
                bCobj = true
                bFirst = true
                //bFollows = true
                delete (skCmod)
                delete (skCobj

 Oh and as Mike said you seem to be able to change

delete (skCmod)
delete (skCobj)
skCmod = createString
skCobj = createString

to

setempty (skCmod)
setempty (skCobj)

 

Well hope that works, it's Friday evening...

 

/sekrbo

 

Re: How to display selected attributes for selected levels in DOORS using DXL?
sreed1141 - Fri Oct 31 17:49:06 EDT 2014

sekrbo - Fri Oct 31 16:42:47 EDT 2014

I think the problem is that the second bool bFirst is about the 'inner itteration' the output that you are creating for each C module, therefore you cannot set bFirst = true for each B object. That is you have to set it for each Cmodule, and that is in the first skiplist loop. So add this

 for s in skCmod do {
    bFollows = true
    if (bFirst) then {

and remove the one in

// inside showIn

  {
            if (depth == 1) then {
                t = probeRichAttr_(othero,"Object Text", false)
                s = ""
                p = ""
                bCobj = true
                bFirst = true
                //bFollows = true
                delete (skCmod)
                delete (skCobj

 Oh and as Mike said you seem to be able to change

delete (skCmod)
delete (skCobj)
skCmod = createString
skCobj = createString

to

setempty (skCmod)
setempty (skCobj)

 

Well hope that works, it's Friday evening...

 

/sekrbo

 

Thanks for the reply. I tried your suggestion, but it did not seem to change anything. I will have to think about it some more to figure out what is going on and where the problem with the looping is. 

Happy Halloween, and happy Friday.